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:
many0,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 IResult
alias, rather than Result. finish is
provided for top-level parsers to integrate with your application’s error reporting.
Error types include:
()ErrorVerboseError- [Custom errors][crate::_topic::error]
Structs
- Default error type, only contains the error’ location and kind
- Accumulates error information while backtracking
Enums
- The
Errenum indicates the parser was not successful - Indicates which parser returned an error
- Contains information on needed data if a parser returned
Incomplete - Error context for
VerboseError
Traits
- Used by the
contextto add custom data to error while backtracking - Equivalent of
Fromimplementation to avoid orphan rules in bits parsers - Extension trait to convert a parser’s
IResultto a more manageable type - Create a new error with an external error, from
std::str::FromStr - The basic
Parsertrait for errors
Functions
- append_errorDeprecatedCombines an existing error with a new one created from the input position and an
ErrorKind. This is useful when backtracking through a parse tree, accumulating error context on the way - contextDeprecatedCreate a new error from an input position, a static string and an existing error. This is used mainly in the context combinator, to add user friendly information to errors when backtracking through a parse tree
- Transforms a
VerboseErrorinto a trace with input position information - dbg_dmpDeprecatedPrints a message and the input if the parser fails.
- make_errorDeprecatedCreates an error from the input position and an
ErrorKind
Type Definitions
- Holds the result of
Parser