pub struct ParseError { /* private fields */ }Expand description
Typed parse error with structured diagnostics and a
backwards compatible Display rendering.
Diagnostic detail lives behind a Box so ParseResult stays small
in Result returns (cold path allocation only).
Implementations§
Source§impl ParseError
impl ParseError
Sourcepub fn pest(
message: String,
expected: Vec<String>,
hint: Option<String>,
ctx: &SpanContext<'_>,
) -> Self
pub fn pest( message: String, expected: Vec<String>, hint: Option<String>, ctx: &SpanContext<'_>, ) -> Self
Pest grammar failure. message must already contain the
parse error (expected: ...) header; the location block is
appended by Display unless already present.
Sourcepub fn invalid_syntax(
command: &str,
message: String,
found: Option<String>,
expected: Vec<String>,
hint: Option<String>,
ctx: &SpanContext<'_>,
) -> Self
pub fn invalid_syntax( command: &str, message: String, found: Option<String>, expected: Vec<String>, hint: Option<String>, ctx: &SpanContext<'_>, ) -> Self
Known command or keyword with malformed arguments.
Sourcepub fn unknown_command(
name: &str,
message: String,
hint: Option<String>,
ctx: &SpanContext<'_>,
) -> Self
pub fn unknown_command( name: &str, message: String, hint: Option<String>, ctx: &SpanContext<'_>, ) -> Self
Truly unknown command name. Callers must ensure classify
sent keyword led lines to invalid_syntax instead.
Sourcepub fn structural(rule: &str, message: String, ctx: &SpanContext<'_>) -> Self
pub fn structural(rule: &str, message: String, ctx: &SpanContext<'_>) -> Self
Structural failure (guards, blocks, WITH_IO, LET, FOR, IF).
Sourcepub fn validation(command: &str, message: String, ctx: &SpanContext<'_>) -> Self
pub fn validation(command: &str, message: String, ctx: &SpanContext<'_>) -> Self
Arity, flag, or static type failure for a known command.
Sourcepub fn with_span(self, ctx: &SpanContext<'_>) -> Self
pub fn with_span(self, ctx: &SpanContext<'_>) -> Self
Enrich an error produced without span context (e.g. from a
direct lower_command call) with the caller’s location.
Existing span fields are only overwritten when the current
value is None, so pest spans are never clobbered.
Sourcepub fn kind(&self) -> &ParseErrorKind
pub fn kind(&self) -> &ParseErrorKind
Machine readable kind.
Sourcepub fn source_line(&self) -> Option<&str>
pub fn source_line(&self) -> Option<&str>
Raw source line text, when available.
Sourcepub fn step_index(&self) -> Option<usize>
pub fn step_index(&self) -> Option<usize>
Zero-based step index, when known.
Trait Implementations§
Source§impl Clone for ParseError
impl Clone for ParseError
Source§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()