pub struct Failure {
pub code: String,
pub row: Option<usize>,
pub col: Option<usize>,
pub message: String,
}Expand description
A parse that failed, as the runner sees it: the code the fixture pins, the position it may pin, and the message a failure report quotes.
This crate cannot name the engine’s error type (it takes no
dependencies), so a suite converts at the boundary, which is a single
closure: .map_err(|e| Failure::new(e.code).at(e.row, e.col)). That
stands in for the errorCode and errorPos hooks of the other two
runtimes, whose runners read those fields off the thrown error by
shape.
Fields§
§code: StringThe error code, or "" when the failure has none.
row: Option<usize>The 1-based source position, when the error reports one.
col: Option<usize>§message: StringThe rendered error, quoted in failure reports.
Implementations§
Source§impl Failure
impl Failure
Sourcepub fn message(message: impl Into<String>) -> Self
pub fn message(message: impl Into<String>) -> Self
A failure with no code at all, only a message: what a parser whose errors are told apart by their text alone produces.
Sourcepub fn at(self, row: usize, col: usize) -> Self
pub fn at(self, row: usize, col: usize) -> Self
Record the 1-based source position the error reports.
Sourcepub fn with_message(self, message: impl Into<String>) -> Self
pub fn with_message(self, message: impl Into<String>) -> Self
Replace the message a report quotes.
Trait Implementations§
impl Eq for Failure
Source§impl Error for Failure
impl Error for Failure
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()