pub struct ParserError<C, I> {
    pub code: C,
    pub span: I,
    pub hints: Vec<Hints<C, I>>,
    pub backtrace: Backtrace,
}
Expand description

Parser error.

Fields§

§code: C

Error code

§span: I

Error span

§hints: Vec<Hints<C, I>>

Extra information

§backtrace: Backtrace

Implementations§

source§

impl<C, I> ParserError<C, I>where C: Code, I: Clone,

source

pub fn new(code: C, span: I) -> Self

New error.

source

pub fn with_cause<E>(self, err: E) -> Selfwhere E: Error + 'static,

With a cause.

source

pub fn with_user_data<Y>(self, user_data: Y) -> Selfwhere Y: 'static,

With user data.

source

pub fn cause(&self) -> Option<&dyn Error>

Finds the first (single) cause.

source

pub fn user_data<Y: 'static>(&self) -> Option<&Y>

Finds the first (single) user data.

source

pub fn error(self) -> Err<Self>

Convert to a nom::Err::Error.

source

pub fn failure(self) -> Err<Self>

Convert to a nom::Err::Failure.

source

pub fn append_err(&mut self, other: ParserError<C, I>)

Adds information from the other parser error to this on.

Adds the others code and span as expect values. Adds all the others expect values.

source

pub fn with_code(self, code: C) -> Self

Convert to a new error code. If the old one differs, it is added to the expect list.

source

pub fn is_expected(&self, code: C) -> bool

Was this one of the expected errors. The main error code is one of the tested values.

source

pub fn expect(&mut self, code: C, span: I)

Add an expected code.

source

pub fn append_expected( &mut self, exp_iter: impl Iterator<Item = SpanAndCode<C, I>> )

Adds some expected codes.

source

pub fn iter_expected(&self) -> impl Iterator<Item = SpanAndCode<C, I>> + '_

Returns the expected codes.

Beware

The main error code is not included here.

source

pub fn suggest(&mut self, code: C, span: I)

Add an suggested code.

source

pub fn is_suggested(&self, code: C) -> bool

Was this one of the expected errors. The main error code is one of the tested values.

source

pub fn append_suggested( &mut self, sug_iter: impl Iterator<Item = SpanAndCode<C, I>> )

Adds some suggested codes.

source

pub fn iter_suggested(&self) -> impl Iterator<Item = SpanAndCode<C, I>> + '_

Returns the suggested codes.

Trait Implementations§

source§

impl<C, I> AppendParserError<Err<ParserError<C, I>>> for ParserError<C, I>where C: Code, I: Clone,

§

type Output = Result<(), Err<ParserError<C, I>>>

Result of the append. Usually (), but for nom::Err::Incomplete the error is not appended but passed through.
source§

fn append(&mut self, err: Err<ParserError<C, I>>) -> Self::Output

Appends
source§

impl<C, I> AppendParserError<ParserError<C, I>> for Err<ParserError<C, I>>where C: Code, I: Clone,

§

type Output = Result<(), Err<ParserError<C, I>>>

Result of the append. Usually (), but for nom::Err::Incomplete the error is not appended but passed through.
source§

fn append(&mut self, err: ParserError<C, I>) -> Self::Output

Appends
source§

impl<C, I> AppendParserError<ParserError<C, I>> for Option<ParserError<C, I>>where C: Code, I: Clone,

§

type Output = ()

Result of the append. Usually (), but for nom::Err::Incomplete the error is not appended but passed through.
source§

fn append(&mut self, err: ParserError<C, I>)

Appends
source§

impl<C, I> AppendParserError for ParserError<C, I>where C: Code, I: Clone,

§

type Output = ()

Result of the append. Usually (), but for nom::Err::Incomplete the error is not appended but passed through.
source§

fn append(&mut self, err: ParserError<C, I>)

Appends
source§

impl<C, I> Debug for ParserError<C, I>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<C, I> Display for ParserError<C, I>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<C, I> ErrOrNomErr for ParserError<C, I>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,

§

type WrappedError = ParserError<C, I>

The base error type.
source§

fn wrap(self) -> Err<Self::WrappedError>

Converts self to a nom::Err wrapped error.
source§

impl<C, I> Error for ParserError<C, I>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,

source§

fn source(&self) -> Option<&(dyn Error + 'static)>

The lower-level source of this error, if any. Read more
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
source§

impl<C, I> From<TokenizerError<C, I>> for ParserError<C, I>where C: Code, I: Clone,

source§

fn from(value: TokenizerError<C, I>) -> Self

Converts to this type from the input type.
source§

impl<C, I> KParseError<C, I> for ParserError<C, I>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,

§

type WrappedError = ParserError<C, I>

The base error type.
source§

fn from(code: C, span: I) -> Self

Create a matching error.
source§

fn with_code(self, code: C) -> Self

Changes the error code.
source§

fn code(&self) -> Option<C>

Returns the error code if self is Result::Err and it’s not nom::Err::Incomplete.
source§

fn span(&self) -> Option<I>

Returns the error span if self is Result::Err and it’s not nom::Err::Incomplete.
source§

fn err(&self) -> Option<&Self::WrappedError>

Returns the error if self is Result::Err and it’s not nom::Err::Incomplete.
source§

fn parts(&self) -> Option<(C, I, &Self::WrappedError)>

Returns all the parts if self is Result::Err and it’s not nom::Err::Incomplete.
source§

impl<C, I> ParseError<I> for ParserError<C, I>where C: Code, I: Clone,

source§

fn or(self, other: Self) -> Self

Combines two parser errors.

source§

fn from_error_kind(input: I, _kind: ErrorKind) -> Self

Creates an error from the input position and an ErrorKind
source§

fn append(_input: I, _kind: ErrorKind, other: Self) -> Self

Combines 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
source§

fn from_char(input: I, _ch: char) -> Self

Creates an error from an input position and an expected character

Auto Trait Implementations§

§

impl<C, I> !RefUnwindSafe for ParserError<C, I>

§

impl<C, I> !Send for ParserError<C, I>

§

impl<C, I> !Sync for ParserError<C, I>

§

impl<C, I> Unpin for ParserError<C, I>where C: Unpin, I: Unpin,

§

impl<C, I> !UnwindSafe for ParserError<C, I>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.