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
impl ExpressionError
Sourcepub fn from_kind(kind: ExpressionErrorKind) -> Self
pub fn from_kind(kind: ExpressionErrorKind) -> Self
Create an error from a structured kind.
Sourcepub fn new(message: impl Into<String>) -> Self
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.
Sourcepub fn integer_overflow() -> Self
pub fn integer_overflow() -> Self
Integer overflow error.
Sourcepub fn division_by_zero(op: &'static str) -> Self
pub fn division_by_zero(op: &'static str) -> Self
Division or modulo by zero.
Sourcepub fn float_error(message: impl Into<String>) -> Self
pub fn float_error(message: impl Into<String>) -> Self
Float produced infinity or NaN.
Sourcepub fn type_error(message: impl Into<String>) -> Self
pub fn type_error(message: impl Into<String>) -> Self
Type mismatch error.
Sourcepub fn index_out_of_bounds(message: impl Into<String>) -> Self
pub fn index_out_of_bounds(message: impl Into<String>) -> Self
Index out of bounds.
Sourcepub fn unsupported(feature: impl Into<String>) -> Self
pub fn unsupported(feature: impl Into<String>) -> Self
Unsupported Python syntax feature.
Sourcepub fn explicit_fail(message: impl Into<String>) -> Self
pub fn explicit_fail(message: impl Into<String>) -> Self
Explicit fail() call.
Sourcepub fn parse_error(message: impl Into<String>) -> Self
pub fn parse_error(message: impl Into<String>) -> Self
A parse-stage error (underlying parser, range expression parser, etc.).
Sourcepub fn expression_too_deep(depth: usize, limit: usize) -> Self
pub fn expression_too_deep(depth: usize, limit: usize) -> Self
AST nesting depth exceeded the configured limit.
Sourcepub fn kind(&self) -> &ExpressionErrorKind
pub fn kind(&self) -> &ExpressionErrorKind
The structured error kind.
Sourcepub fn message(&self) -> String
pub fn message(&self) -> String
The human-readable error message (the Display output of the kind).
Sourcepub fn sub_errors(&self) -> &[ExpressionError]
pub fn sub_errors(&self) -> &[ExpressionError]
Sub-errors for compound failures (e.g., both branches of an if/else).
Sourcepub fn with_sub_errors(self, sub_errors: Vec<ExpressionError>) -> Self
pub fn with_sub_errors(self, sub_errors: Vec<ExpressionError>) -> Self
Attach sub-errors (consumes and returns self for chaining).
Sourcepub fn col_offset(&self) -> Option<usize>
pub fn col_offset(&self) -> Option<usize>
The start column offset within the expression, if attached.
Sourcepub fn end_col_offset(&self) -> Option<usize>
pub fn end_col_offset(&self) -> Option<usize>
The end column offset within the expression, if attached.
Sourcepub fn caret_offset(&self) -> Option<usize>
pub fn caret_offset(&self) -> Option<usize>
The caret offset relative to col_offset, if attached.
Sourcepub fn with_node(self, expr_source: &str, node: &Expr) -> Self
pub fn with_node(self, expr_source: &str, node: &Expr) -> Self
Attach expression source and AST node span for caret formatting.
Sourcepub fn with_span(self, expr_source: &str, col: usize, end_col: usize) -> Self
pub fn with_span(self, expr_source: &str, col: usize, end_col: usize) -> Self
Attach expression source with explicit span (no AST node).
Sourcepub fn set_source_span(
&mut self,
expr_source: &str,
col: usize,
end_col: usize,
caret_offset: usize,
)
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).
Sourcepub fn message_with_expr_prefix(&self, prefix: &str) -> String
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
impl Clone for ExpressionError
Source§fn clone(&self) -> ExpressionError
fn clone(&self) -> ExpressionError
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 ExpressionError
impl Debug for ExpressionError
Source§impl Display for ExpressionError
impl Display for ExpressionError
Source§impl Error for ExpressionError
impl Error for ExpressionError
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 From<RangeExprError> for ExpressionError
impl From<RangeExprError> for ExpressionError
Source§fn from(e: RangeExprError) -> Self
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
impl From<SymbolTableError> for ExpressionError
Source§fn from(e: SymbolTableError) -> Self
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§
impl Freeze for ExpressionError
impl RefUnwindSafe for ExpressionError
impl Send for ExpressionError
impl Sync for ExpressionError
impl Unpin for ExpressionError
impl UnsafeUnpin for ExpressionError
impl UnwindSafe for ExpressionError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more