pub struct ParseError {
pub message: String,
pub offset: Option<usize>,
pub line: Option<u32>,
pub column: Option<usize>,
pub length: Option<usize>,
pub severity: Option<DiagnosticSeverity>,
pub code: Option<String>,
pub expected: Option<String>,
pub found: Option<String>,
pub suggestion: Option<String>,
pub category: Option<DiagnosticCategory>,
pub is_cascade: Option<bool>,
}Expand description
Error returned when parsing fails.
Fields§
§message: StringHuman-readable description of the error.
offset: Option<usize>Optional byte offset in the input where the error occurred.
line: Option<u32>Optional line number (1-based).
column: Option<usize>Optional column (1-based).
length: Option<usize>Optional length of the error span in bytes (for LSP range end).
severity: Option<DiagnosticSeverity>Severity (defaults to Error when not set).
code: Option<String>Optional code for quick fixes or documentation (e.g. “expected_keyword”).
expected: Option<String>What was expected at this position (e.g. “‘;’ or ‘}’”, “‘package’ or ‘namespace’”).
found: Option<String>Snippet of what was found at the error position (for display).
suggestion: Option<String>Short hint on how to fix the error.
category: Option<DiagnosticCategory>High-level diagnostic category used by clients to classify failures.
is_cascade: Option<bool>When true, this diagnostic is likely a consequence of an earlier error in the same body.
Implementations§
Source§impl ParseError
impl ParseError
pub fn new(message: impl Into<String>) -> Self
pub fn with_offset(self, offset: usize) -> Self
Sourcepub fn with_location(self, offset: usize, line: u32, column: usize) -> Self
pub fn with_location(self, offset: usize, line: u32, column: usize) -> Self
Set offset, line, and column for error location.
pub fn with_length(self, length: usize) -> Self
pub fn with_severity(self, severity: DiagnosticSeverity) -> Self
pub fn with_code(self, code: impl Into<String>) -> Self
pub fn with_expected(self, expected: impl Into<String>) -> Self
pub fn with_found(self, found: impl Into<String>) -> Self
pub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
pub fn with_category(self, category: DiagnosticCategory) -> Self
pub fn with_is_cascade(self, is_cascade: bool) -> Self
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
impl Eq 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 PartialEq for ParseError
impl PartialEq for ParseError
Source§fn eq(&self, other: &ParseError) -> bool
fn eq(&self, other: &ParseError) -> bool
self and other values to be equal, and is used by ==.