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>,
}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.
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
Trait Implementations§
Source§impl Clone for ParseError
impl Clone for ParseError
Source§fn clone(&self) -> ParseError
fn clone(&self) -> ParseError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl PartialEq for ParseError
impl PartialEq for ParseError
impl Eq for ParseError
impl StructuralPartialEq for ParseError
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
Mutably borrows from an owned value. Read more