Struct kparse::parser_error::ParserError
source · 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,
impl<C, I> ParserError<C, I>where C: Code, I: Clone,
sourcepub fn with_cause<E>(self, err: E) -> Selfwhere
E: Error + 'static,
pub fn with_cause<E>(self, err: E) -> Selfwhere E: Error + 'static,
With a cause.
sourcepub fn with_user_data<Y>(self, user_data: Y) -> Selfwhere
Y: 'static,
pub fn with_user_data<Y>(self, user_data: Y) -> Selfwhere Y: 'static,
With user data.
sourcepub fn append_err(&mut self, other: ParserError<C, I>)
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.
sourcepub fn with_code(self, code: C) -> Self
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.
sourcepub fn is_expected(&self, code: C) -> bool
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.
sourcepub fn append_expected(
&mut self,
exp_iter: impl Iterator<Item = SpanAndCode<C, I>>
)
pub fn append_expected( &mut self, exp_iter: impl Iterator<Item = SpanAndCode<C, I>> )
Adds some expected codes.
sourcepub fn iter_expected(&self) -> impl Iterator<Item = SpanAndCode<C, I>> + '_
pub fn iter_expected(&self) -> impl Iterator<Item = SpanAndCode<C, I>> + '_
sourcepub fn is_suggested(&self, code: C) -> bool
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.
sourcepub fn append_suggested(
&mut self,
sug_iter: impl Iterator<Item = SpanAndCode<C, I>>
)
pub fn append_suggested( &mut self, sug_iter: impl Iterator<Item = SpanAndCode<C, I>> )
Adds some suggested codes.
sourcepub fn iter_suggested(&self) -> impl Iterator<Item = SpanAndCode<C, I>> + '_
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,
impl<C, I> AppendParserError<Err<ParserError<C, I>>> for ParserError<C, I>where C: Code, I: Clone,
source§impl<C, I> AppendParserError<ParserError<C, I>> for Err<ParserError<C, I>>where
C: Code,
I: Clone,
impl<C, I> AppendParserError<ParserError<C, I>> for Err<ParserError<C, I>>where C: Code, I: Clone,
source§impl<C, I> AppendParserError<ParserError<C, I>> for Option<ParserError<C, I>>where
C: Code,
I: Clone,
impl<C, I> AppendParserError<ParserError<C, I>> for Option<ParserError<C, I>>where C: Code, I: Clone,
source§impl<C, I> AppendParserError for ParserError<C, I>where
C: Code,
I: Clone,
impl<C, I> AppendParserError for ParserError<C, I>where C: Code, I: Clone,
source§impl<C, I> Debug for ParserError<C, I>where
C: Code,
I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,
impl<C, I> Debug for ParserError<C, I>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,
source§impl<C, I> Display for ParserError<C, I>where
C: Code,
I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,
impl<C, I> Display for ParserError<C, I>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,
source§impl<C, I> ErrOrNomErr for ParserError<C, I>where
C: Code,
I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,
impl<C, I> ErrOrNomErr for ParserError<C, I>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,
§type WrappedError = ParserError<C, I>
type WrappedError = ParserError<C, I>
The base error type.
source§fn wrap(self) -> Err<Self::WrappedError>
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,
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)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl<C, I> From<TokenizerError<C, I>> for ParserError<C, I>where
C: Code,
I: Clone,
impl<C, I> From<TokenizerError<C, I>> for ParserError<C, I>where C: Code, I: Clone,
source§fn from(value: TokenizerError<C, I>) -> Self
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,
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>
type WrappedError = ParserError<C, I>
The base error type.
source§fn code(&self) -> Option<C>
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>
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>
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)>
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,
impl<C, I> ParseError<I> for ParserError<C, I>where C: Code, I: Clone,
source§fn from_error_kind(input: I, _kind: ErrorKind) -> Self
fn from_error_kind(input: I, _kind: ErrorKind) -> Self
Creates an error from the input position and an ErrorKind
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more