Enum pest::Error
[−]
[src]
pub enum Error<R, I: Input> { ParsingError { positives: Vec<R>, negatives: Vec<R>, pos: Position<I>, }, CustomErrorPos { message: String, pos: Position<I>, }, CustomErrorSpan { message: String, span: Span<I>, }, }
An enum
which defines possible errors.
Variants
ParsingError
Generated parsing error with expected and unexpected Rule
s and a position
Fields of ParsingError
positives: Vec<R> | Positive attempts |
negatives: Vec<R> | Negative attempts |
pos: Position<I> | Deepest position of attempts |
CustomErrorPos
Custom error with a message and a position
Fields of CustomErrorPos
message: String | Short explanation |
pos: Position<I> | Error |
CustomErrorSpan
Custom error with a message and a span defined by a start and end position
Fields of CustomErrorSpan
message: String | Short explanation |
span: Span<I> | Error |
Methods
impl<R: RuleType, I: Input> Error<R, I>
[src]
fn renamed_rules<F>(self, f: F) -> Error<R, I> where
F: FnMut(&R) -> String,
F: FnMut(&R) -> String,
Renames all Rule
s from a ParsingError
variant returning a CustomErrorPos
. It does
nothing when called on CustomErrorPos
and CustomErrorSpan
variants.
Useful in order to rename verbose rules or have detailed per-Rule
formatting.
Examples
Error::ParsingError { positives: vec![Rule::open_paren], negatives: vec![Rule::closed_paren], pos: pos }.renamed_rules(|rule| { match *rule { Rule::open_paren => "(".to_owned(), Rule::closed_paren => "closed paren".to_owned() } });
Trait Implementations
impl<R: Debug, I: Debug + Input> Debug for Error<R, I>
[src]
impl<R: Debug, I: Input> Display for Error<R, I>
[src]
impl<R: Clone, I: Input> Clone for Error<R, I>
[src]
fn clone(&self) -> Error<R, I>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<R: PartialEq, I: Input> PartialEq for Error<R, I>
[src]
fn eq(&self, other: &Error<R, I>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.