pub struct ParseError {
pub message: String,
pub span: Span,
pub line: usize,
pub col: usize,
}Expand description
Why a source did not parse, and where.
Structured, and located at the boundary. message says what was
expected and what was found, in blue’s own words; span is the byte range
of the offending text; line and col are that range’s start, 1-based,
with the column counted in characters. Every public entry point fills
line/col from the source it was given, so Display reads
3:7: expected ), found ]`` and never a byte offset.
The byte offsets used to BE the display (… at 10..11), and a Rust
Debug rendering named the token (found Ident("y")). Both are facts
about the implementation; neither is something an author can act on.
The span stays, as data, for any consumer that needs to point into the
buffer — an editor squiggle, a diagnostic code attached downstream.
Fields§
§message: String§span: Span§line: usize1-based line of span.start.
col: usize1-based column of span.start, in characters.
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()