Skip to main content

ExpressionError

Struct ExpressionError 

Source
pub struct ExpressionError { /* private fields */ }
Expand description

Base error for expression evaluation.

Wraps an ExpressionErrorKind with optional source location context for caret-style error formatting.

Internally boxed (8 bytes on stack) to keep Result<ExprValue, ExpressionError> compact. Same pattern as serde_json::Error.

Implementations§

Source§

impl ExpressionError

Source

pub fn from_kind(kind: ExpressionErrorKind) -> Self

Create an error from a structured kind.

Source

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

Create an error with a plain message string.

This is a convenience for call sites that don’t need a structured kind. Prefer ExpressionError::from_kind with a specific variant when the error category is known.

Source

pub fn integer_overflow() -> Self

Integer overflow error.

Source

pub fn division_by_zero(op: &'static str) -> Self

Division or modulo by zero.

Source

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

Float produced infinity or NaN.

Source

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

Type mismatch error.

Source

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

Index out of bounds.

Source

pub fn unsupported(feature: impl Into<String>) -> Self

Unsupported Python syntax feature.

Source

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

Explicit fail() call.

Source

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

A parse-stage error (underlying parser, range expression parser, etc.).

Source

pub fn expression_too_deep(depth: usize, limit: usize) -> Self

AST nesting depth exceeded the configured limit.

Source

pub fn kind(&self) -> &ExpressionErrorKind

The structured error kind.

Source

pub fn message(&self) -> String

The human-readable error message (the Display output of the kind).

Source

pub fn sub_errors(&self) -> &[ExpressionError]

Sub-errors for compound failures (e.g., both branches of an if/else).

Source

pub fn with_sub_errors(self, sub_errors: Vec<ExpressionError>) -> Self

Attach sub-errors (consumes and returns self for chaining).

Source

pub fn expr(&self) -> Option<&str>

The expression source text, if attached.

Source

pub fn col_offset(&self) -> Option<usize>

The start column offset within the expression, if attached.

Source

pub fn end_col_offset(&self) -> Option<usize>

The end column offset within the expression, if attached.

Source

pub fn caret_offset(&self) -> Option<usize>

The caret offset relative to col_offset, if attached.

Source

pub fn with_node(self, expr_source: &str, node: &Expr) -> Self

Attach expression source and AST node span for caret formatting.

Source

pub fn with_span(self, expr_source: &str, col: usize, end_col: usize) -> Self

Attach expression source with explicit span (no AST node).

Source

pub fn set_source_span( &mut self, expr_source: &str, col: usize, end_col: usize, caret_offset: usize, )

Set the expression source and span directly (for cases where with_node cannot be used because the span is computed manually).

Source

pub fn message_with_expr_prefix(&self, prefix: &str) -> String

Format the error with a prefix prepended to the expression line.

The caret position is shifted right by prefix.len() so it still points at the correct column in the combined prefix + expr string. Used for let-binding errors where the expression is part of a larger construct like "x = Param.Frame + \"oops\"".

Only applies to single-line expressions with caret indicators. Falls back to the normal Display output for multi-line or context-free errors.

Trait Implementations§

Source§

impl Clone for ExpressionError

Source§

fn clone(&self) -> ExpressionError

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 ExpressionError

Source§

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

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

impl Display for ExpressionError

Source§

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

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

impl Error for ExpressionError

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<RangeExprError> for ExpressionError

Source§

fn from(e: RangeExprError) -> Self

Lift a range-expression parse error into an ExpressionError.

If the error carries a position, attach the source string with a span covering the single character at that offset so the standard caret renderer points at the failure. Without a position, fall back to the stringified Display form.

Source§

impl From<SymbolTableError> for ExpressionError

Source§

fn from(e: SymbolTableError) -> Self

Bubble a symbol-table conflict up as an ExpressionError::Other.

The full SymbolTableError message is preserved verbatim so callers can still see which key was being set and what it conflicted with. Call sites that have an AST node available can further attach .with_node(...) / .with_span(...) for caret-annotated output.

Auto Trait Implementations§

Blanket Implementations§

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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToCompactString for T
where T: Display,

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.