Expand description
§Error management
Errors are designed with multiple needs in mind:
- Accumulate more context as the error goes up the parser chain
- Distinguish between recoverable errors, unrecoverable errors, and more data is needed
- Have a very low overhead, as errors are often discarded by the calling parser (examples:
repeat
,alt
) - Can be modified according to the user’s needs, because some languages need a lot more information
- Help thread-through the stream
To abstract these needs away from the user, generally winnow
parsers use the PResult
alias, rather than Result
. Parser::parse
is a top-level operation
that can help convert to a Result
for integrating with your application’s error reporting.
Error types include:
()
ErrorKind
InputError
(mostly for testing)ContextError
TreeError
(mostly for testing)- [Custom errors][crate::_topic::error]
Structs§
- Accumulate context while backtracking errors
- Capture input on error
- See
Parser::parse
Enums§
- Add parse error state to
ParserError
s - Provide some minor debug context for errors
- Contains information on needed data if a parser returned
Incomplete
- Additional parse context for
ContextError
added viaParser::context
- See
StrContext
- Trace all error paths, particularly for tests
- See
TreeError::Stack
Traits§
- Used by
Parser::context
to add custom data to error while backtracking - Equivalent of
From
implementation to avoid orphan rules in bits parsers - Create a new error with an external error, from
std::str::FromStr
- The basic
Parser
trait for errors
Type Aliases§
- For use with
Parser::parse_peek
which allows the input stream to be threaded through a parser. - For use with
Parser::parse_next