Skip to main content

ParserError

Enum ParserError 

Source
pub enum ParserError {
    SyntaxError {
        message: String,
        position: SourcePosition,
        expected: Option<Vec<String>>,
    },
    SemanticError {
        message: String,
        position: Option<SourcePosition>,
    },
    LexicalError {
        message: String,
        position: SourcePosition,
    },
    BackendError {
        backend: String,
        message: String,
        position: Option<SourcePosition>,
    },
    TypeError {
        message: String,
        expected_type: Option<String>,
        actual_type: Option<String>,
        position: Option<SourcePosition>,
    },
    ConfigurationError {
        message: String,
    },
    UnsupportedFeature {
        backend: String,
        feature: String,
        message: String,
    },
    Timeout {
        message: String,
        timeout_duration: Duration,
    },
    ResourceLimit {
        message: String,
        limit_type: String,
        current_value: u64,
        max_value: u64,
    },
    InternalError {
        message: String,
        cause: Option<String>,
    },
}
Expand description

Parser-specific error type

Variants§

§

SyntaxError

Syntax error during parsing

Fields

§message: String
§expected: Option<Vec<String>>
§

SemanticError

Semantic validation error

Fields

§message: String
§

LexicalError

Lexical analysis error

Fields

§message: String
§

BackendError

Parser backend error

Fields

§backend: String
§message: String
§

TypeError

Type validation error

Fields

§message: String
§expected_type: Option<String>
§actual_type: Option<String>
§

ConfigurationError

Configuration error

Fields

§message: String
§

UnsupportedFeature

Unsupported feature error

Fields

§backend: String
§feature: String
§message: String
§

Timeout

Timeout error

Fields

§message: String
§timeout_duration: Duration
§

ResourceLimit

Resource limit exceeded

Fields

§message: String
§limit_type: String
§current_value: u64
§max_value: u64
§

InternalError

Internal parser error

Fields

§message: String

Implementations§

Source§

impl ParserError

Source

pub fn syntax(message: impl Into<String>, position: SourcePosition) -> Self

Create a syntax error

Source

pub fn syntax_with_expected( message: impl Into<String>, position: SourcePosition, expected: Vec<String>, ) -> Self

Create a syntax error with expected tokens

Source

pub fn semantic(message: impl Into<String>) -> Self

Create a semantic error

Source

pub fn semantic_at(message: impl Into<String>, position: SourcePosition) -> Self

Create a semantic error with position

Source

pub fn lexical(message: impl Into<String>, position: SourcePosition) -> Self

Create a lexical error

Source

pub fn backend(backend: impl Into<String>, message: impl Into<String>) -> Self

Create a backend error

Source

pub fn backend_at( backend: impl Into<String>, message: impl Into<String>, position: SourcePosition, ) -> Self

Create a backend error with position

Source

pub fn type_error(message: impl Into<String>) -> Self

Create a type error

Source

pub fn type_mismatch( expected: impl Into<String>, actual: impl Into<String>, position: Option<SourcePosition>, ) -> Self

Create a type error with expected and actual types

Source

pub fn configuration(message: impl Into<String>) -> Self

Create a configuration error

Source

pub fn unsupported_feature( backend: impl Into<String>, feature: impl Into<String>, ) -> Self

Create an unsupported feature error

Source

pub fn internal(message: impl Into<String>) -> Self

Create an internal error

Source

pub fn internal_with_cause( message: impl Into<String>, cause: impl Display, ) -> Self

Create an internal error with cause

Source

pub fn timeout(duration_ms: u64) -> Self

Create a timeout error

Source

pub fn resource_limit( resource: impl Into<String>, limit: u64, actual: u64, ) -> Self

Create a resource limit exceeded error

Source

pub fn position(&self) -> Option<&SourcePosition>

Get the position associated with this error (if any)

Source

pub fn message(&self) -> String

Get the error message

Source

pub fn is_recoverable(&self) -> bool

Check if this error is recoverable.

Recoverable errors include those where switching backends, retrying with a longer timeout, or raising a resource limit may allow progress.

Source

pub fn category(&self) -> &ErrorCategory

Get the error category

Source

pub fn severity(&self) -> &ErrorSeverity

Get the error severity

Source

pub fn recovery_suggestions(&self) -> Vec<String>

Get suggested recovery actions

Trait Implementations§

Source§

impl Clone for ParserError

Source§

fn clone(&self) -> ParserError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParserError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ParserError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for ParserError

1.30.0 · Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<ParserError> for Error

Source§

fn from(err: ParserError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.