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 ModalResult
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:
EmptyError
when the reason for failure doesn’t matterContextError
InputError
(mostly for testing)TreeError
(mostly for testing)- Custom errors
Structs§
- Context
Error - Accumulate context while backtracking errors
- Empty
Error - Track an error occurred without any other
StrContext
- Input
Error - Capture input on error
- Parse
Error - See
Parser::parse
- Tree
Error Base std
- See
TreeErrorFrame::Kind
,ParserError::append
- Tree
Error Context std
- See
TreeErrorFrame::Context
,AddContext::add_context
Enums§
- ErrMode
- Add parse error state to
ParserError
s - Needed
- Contains information on needed data if a parser returned
Incomplete
- StrContext
- Additional parse context for
ContextError
added viaParser::context
- StrContext
Value - See
StrContext
- Tree
Error std
- Trace all error paths, particularly for tests
- Tree
Error Frame std
- See
TreeError::Stack
Traits§
- AddContext
- Used by
Parser::context
to add custom data to error while backtracking - Error
Convert - Equivalent of
From
implementation to avoid orphan rules in bits parsers - From
External Error - Create a new error with an external error, from
std::str::FromStr
- From
Recoverable Error unstable-recover
andstd
- Capture context from when an error was recovered
- Modal
Error - Manipulate the how parsers respond to this error
- Parser
Error - The basic
Parser
trait for errors
Type Aliases§
- Modal
Result - Modal error reporting for
Parser::parse_next
- Result
- By default, the error type (
E
) isContextError
.