pub enum Error<T, R> {
    Unexpected(Info<T, R>),
    Expected(Info<T, R>),
    Message(Info<T, R>),
    Other(Box<dyn StdError + Send + Sync>),
}
Expand description

Enum used to store information about an error that has occurred during parsing.

Variants

Unexpected(Info<T, R>)

Error indicating an unexpected token has been encountered in the stream

Expected(Info<T, R>)

Error indicating that the parser expected something else

Message(Info<T, R>)

Generic message

Other(Box<dyn StdError + Send + Sync>)

Variant for containing other types of errors

Implementations

Returns the end_of_input error.

Formats a slice of errors in a human readable way.


let input = r"
  ,123
";
let result = spaces().silent().with(char('.').or(char('a')).or(digit()))
    .easy_parse(position::Stream::new(input));
let m = format!("{}", result.unwrap_err());
let expected = r"Parse error at line: 2, column: 3
Unexpected `,`
Expected `.`, `a` or digit
";
assert_eq!(m, expected);

Trait Implementations

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Constructs an empty error. Read more

Creates a ParseError from a single Self::StreamError

Sets the position of this ParseError

Adds a StreamError to self. Read more

Sets info as the only Expected error of self

Does a best-effort conversion of self into another ParseError

Merges two errors. If they exist at the same position the errors of other are added to self (using the semantics of add). If they are not at the same position the error furthest ahead are returned, ignoring the other ParseError. Read more

Removes any expected errors currently in self

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Converts self into a different StreamError type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts to this type from the input type.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.