Enum ExprError

Source
pub enum ExprError {
    Parse(ParseFloatError),
    Tokenizer(String),
    Syntax(String),
    UnmatchedParenthesis {
        position: usize,
        found: String,
    },
    UnknownVariable {
        name: String,
    },
    UnknownFunction {
        name: String,
    },
    InvalidFunctionCall {
        name: String,
        expected: usize,
        found: usize,
    },
    ArrayIndexOutOfBounds {
        name: String,
        index: usize,
        len: usize,
    },
    AttributeNotFound {
        base: String,
        attr: String,
    },
    Other(String),
    RecursionLimit(String),
}
Expand description

Error type for expression parsing and evaluation.

This enum represents all possible errors that can occur during expression parsing, tokenization, and evaluation. It provides specific error variants with detailed information to help diagnose and fix issues.

Variants§

§

Parse(ParseFloatError)

Error when parsing a floating point number.

This occurs when a string cannot be converted to a floating point number. For example, “3.a” is not a valid floating point number.

§

Tokenizer(String)

Error during lexical analysis (tokenization).

This occurs when the tokenizer encounters invalid tokens or unknown characters that cannot be processed. The string contains a detailed error message.

§

Syntax(String)

Error during syntax analysis.

This occurs when the parser encounters unexpected tokens, incorrect expression structure, or other syntax issues. The string contains a detailed error message.

§

UnmatchedParenthesis

Error for unmatched parentheses in an expression.

This provides the position of the unmatched parenthesis and the specific parenthesis character that was found without a matching pair.

Fields

§position: usize
§found: String
§

UnknownVariable

Error when a variable referenced in an expression is not defined.

To resolve this error, make sure the variable is registered in the evaluation context using EvalContext::set_parameter.

Fields

§name: String
§

UnknownFunction

Unknown function error

This error is returned when a function is called that is not registered in the context and is not a built-in (if built-ins are enabled). If the no-builtin-math feature is enabled, users must register their own native functions for all required math operations.

To resolve this error, register a native function with EvalContext::register_native_function or an expression function with EvalContext::register_expression_function.

Fields

§name: String
§

InvalidFunctionCall

Error when a function is called with the wrong number of arguments.

This occurs when a function is called with fewer or more arguments than it expects. The error includes the function name, the expected number of arguments, and the actual number of arguments provided.

Fields

§name: String

Name of the function that was called

§expected: usize

Expected number of arguments

§found: usize

Actual number of arguments provided

§

ArrayIndexOutOfBounds

Error when an array index is out of bounds.

This occurs when trying to access an array element with an index that exceeds the array’s length. The error includes the array name, the attempted index, and the actual length of the array.

Fields

§name: String

Name of the array being accessed

§index: usize

Index that was attempted to be accessed

§len: usize

Actual length of the array

§

AttributeNotFound

Error when an attribute access is attempted on an object that doesn’t have that attribute.

This occurs when using the dot notation (e.g., object.attribute) and the attribute does not exist on the specified object.

Fields

§base: String

The base object name

§attr: String

The attribute name that was not found

§

Other(String)

General-purpose error for any other error conditions.

This is used for errors that don’t fit into other specific categories. The string contains a detailed error message.

§

RecursionLimit(String)

Error when the recursion limit is exceeded during expression evaluation.

This usually happens with deeply nested expressions or recursive function calls. To resolve this, simplify the expression or increase the recursion limit if possible.

Trait Implementations§

Source§

impl Clone for ExprError

Source§

fn clone(&self) -> ExprError

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ExprError

Source§

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

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

impl Display for ExprError

Source§

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

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

impl From<ParseFloatError> for ExprError

Source§

fn from(err: ParseFloatError) -> ExprError

Converts to this type from the input type.
Source§

impl From<String> for ExprError

Source§

fn from(err: String) -> ExprError

Converts to this type from the input type.

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> 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.