pub(crate) struct ContextError<C = StrContext> {
context: Vec<C>,
cause: Option<Box<dyn Error + Send + Sync>>,
}
Expand description
Accumulate context while backtracking errors
See the [tutorial][crate::_tutorial::chapter_7#error-adaptation-and-rendering] for an example of how to adapt this to an application error with custom rendering.
Fields§
§context: Vec<C>
§cause: Option<Box<dyn Error + Send + Sync>>
Implementations§
Source§impl<C> ContextError<C>
impl<C> ContextError<C>
Sourcepub fn new() -> ContextError<C>
pub fn new() -> ContextError<C>
Create an empty error
Sourcepub fn context(&self) -> impl Iterator<Item = &C>
pub fn context(&self) -> impl Iterator<Item = &C>
Access context from Parser::context
Trait Implementations§
Source§impl<C, I> AddContext<I, C> for ContextError<C>where
I: Stream,
impl<C, I> AddContext<I, C> for ContextError<C>where
I: Stream,
Source§fn add_context(
self,
_input: &I,
_token_start: &<I as Stream>::Checkpoint,
context: C,
) -> ContextError<C>
fn add_context( self, _input: &I, _token_start: &<I as Stream>::Checkpoint, context: C, ) -> ContextError<C>
Append to an existing error custom data Read more
Source§impl<C> Clone for ContextError<C>where
C: Clone,
impl<C> Clone for ContextError<C>where
C: Clone,
Source§fn clone(&self) -> ContextError<C>
fn clone(&self) -> ContextError<C>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<C> Debug for ContextError<C>where
C: Debug,
impl<C> Debug for ContextError<C>where
C: Debug,
Source§impl<C> Default for ContextError<C>
impl<C> Default for ContextError<C>
Source§fn default() -> ContextError<C>
fn default() -> ContextError<C>
Returns the “default value” for a type. Read more
Source§impl Display for ContextError
impl Display for ContextError
Source§impl<C> ErrorConvert<ContextError<C>> for ContextError<C>
impl<C> ErrorConvert<ContextError<C>> for ContextError<C>
Source§fn convert(self) -> ContextError<C>
fn convert(self) -> ContextError<C>
Transform to another error type
Source§impl<C, I, E> FromExternalError<I, E> for ContextError<C>
impl<C, I, E> FromExternalError<I, E> for ContextError<C>
Source§fn from_external_error(_input: &I, e: E) -> ContextError<C>
fn from_external_error(_input: &I, e: E) -> ContextError<C>
Like
ParserError::from_input
but also include an external error.Source§impl<I, C> ParserError<I> for ContextError<C>where
I: Stream,
impl<I, C> ParserError<I> for ContextError<C>where
I: Stream,
Source§type Inner = ContextError<C>
type Inner = ContextError<C>
Generally,
Self
Read moreSource§fn from_input(_input: &I) -> ContextError<C>
fn from_input(_input: &I) -> ContextError<C>
Creates an error from the input position
Source§fn into_inner(
self,
) -> Result<<ContextError<C> as ParserError<I>>::Inner, ContextError<C>>
fn into_inner( self, ) -> Result<<ContextError<C> as ParserError<I>>::Inner, ContextError<C>>
Unwrap the mode, returning the underlying error, if present
Source§fn assert(input: &I, _message: &'static str) -> Selfwhere
I: Debug,
fn assert(input: &I, _message: &'static str) -> Selfwhere
I: Debug,
Process a parser assertion
Source§fn incomplete(input: &I, _needed: Needed) -> Self
fn incomplete(input: &I, _needed: Needed) -> Self
There was not enough data to determine the appropriate action Read more
Source§fn append(self, _input: &I, _token_start: &<I as Stream>::Checkpoint) -> Self
fn append(self, _input: &I, _token_start: &<I as Stream>::Checkpoint) -> Self
Like
ParserError::from_input
but merges it with the existing error. Read moreSource§fn is_backtrack(&self) -> bool
fn is_backtrack(&self) -> bool
Is backtracking and trying new parse branches allowed?
Source§impl<C> PartialEq for ContextError<C>where
C: PartialEq,
impl<C> PartialEq for ContextError<C>where
C: PartialEq,
Auto Trait Implementations§
impl<C> Freeze for ContextError<C>
impl<C = StrContext> !RefUnwindSafe for ContextError<C>
impl<C> Send for ContextError<C>where
C: Send,
impl<C> Sync for ContextError<C>where
C: Sync,
impl<C> Unpin for ContextError<C>where
C: Unpin,
impl<C = StrContext> !UnwindSafe for ContextError<C>
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