pub struct ParseError {
pub message: String,
pub position: Position,
pub expected: Vec<String>,
pub kind: ParseErrorKind,
}Expand description
Parse error
Fields§
§message: StringError message
position: PositionPosition where error occurred
expected: Vec<String>Expected tokens (for better error messages)
kind: ParseErrorKindOptional structured kind for hardening / DoS errors
Implementations§
Source§impl ParseError
impl ParseError
Sourcepub fn expected(expected: Vec<&str>, found: &Token, position: Position) -> Self
pub fn expected(expected: Vec<&str>, found: &Token, position: Position) -> Self
Create error with expected tokens
found is rendered through SafeTokenDisplay so caller-controlled
bytes inside Token::Ident / Token::String / Token::JsonLiteral /
Token::Float / Token::Integer payloads are escaped via Rust’s
escape_debug rules (CR / LF / NUL / quote bytes become \n,
\r, \0, \", …). Static keyword and punctuation arms keep their
existing UPPER-CASE rendering so error messages and snapshot tests
stay readable. This prevents F-05 smuggling through the downstream
JSON / audit / log / gRPC sinks that embed ParseError::message.
Sourcepub fn unsupported_recognized_token(
found: &Token,
position: Position,
) -> Option<Self>
pub fn unsupported_recognized_token( found: &Token, position: Position, ) -> Option<Self>
Create an error when a lexer-known keyword appears in a parser position where that keyword has no supported production.
Sourcepub fn depth_limit(
limit_name: &'static str,
value: usize,
position: Position,
) -> Self
pub fn depth_limit( limit_name: &'static str, value: usize, position: Position, ) -> Self
Recursion depth limit hit. The structured kind carries the
name + numeric value so the snapshot/property harness can
pattern-match without string slicing.
Sourcepub fn input_too_large(
limit_name: &'static str,
value: usize,
position: Position,
) -> Self
pub fn input_too_large( limit_name: &'static str, value: usize, position: Position, ) -> Self
Input bytes exceeded the configured cap.
Sourcepub fn identifier_too_long(
limit_name: &'static str,
value: usize,
position: Position,
) -> Self
pub fn identifier_too_long( limit_name: &'static str, value: usize, position: Position, ) -> Self
Identifier exceeded the configured character cap.
Sourcepub fn value_out_of_range(
field: &'static str,
constraint: &'static str,
position: Position,
) -> Self
pub fn value_out_of_range( field: &'static str, constraint: &'static str, position: Position, ) -> Self
A literal value lies outside the allowed range for its slot.
The free-text constraint is included verbatim in the message
so callers can render a single line without re-formatting.
Trait Implementations§
Source§impl Clone for ParseError
impl Clone for ParseError
Source§fn clone(&self) -> ParseError
fn clone(&self) -> ParseError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParseError
impl Debug for ParseError
Source§impl Display for ParseError
impl Display for ParseError
Source§impl Error for ParseError
impl Error for ParseError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<LexerError> for ParseError
impl From<LexerError> for ParseError
Source§fn from(e: LexerError) -> Self
fn from(e: LexerError) -> Self
Auto Trait Implementations§
impl Freeze for ParseError
impl RefUnwindSafe for ParseError
impl Send for ParseError
impl Sync for ParseError
impl Unpin for ParseError
impl UnsafeUnpin for ParseError
impl UnwindSafe for ParseError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request