ExprError

Enum ExprError 

Source
#[repr(C, align(4))]
pub enum ExprError {
Show 16 variants 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, }, DivideByZero, Other(String), RecursionLimit(String), CapacityExceeded(&'static str), StringTooLong(String, usize), DuplicateParameter(String), InvalidParameterIndex(usize),
}
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 libm feature is not 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

§

DivideByZero

Error when division by zero is attempted.

This occurs when a division operation has a zero divisor.

§

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.

§

CapacityExceeded(&'static str)

Error when capacity is exceeded for a heapless container.

This occurs when trying to insert into a full heapless container. The string indicates which container type exceeded capacity.

§

StringTooLong(String, usize)

Error when a string is too long for heapless string buffer.

This occurs when trying to create a heapless string that exceeds the maximum string length limit.

§

DuplicateParameter(String)

Error when attempting to add a parameter with a name that already exists.

This occurs when trying to register a parameter that has already been registered.

§

InvalidParameterIndex(usize)

Error when attempting to access a parameter by an invalid index.

This occurs when the provided index is out of bounds for the parameter list.

Implementations§

Source§

impl ExprError

Source

pub fn error_code(&self) -> i32

Convert this error to a numeric error code for FFI

Trait Implementations§

Source§

impl Clone for ExprError

Source§

fn clone(&self) -> ExprError

Returns a duplicate of the value. Read more
1.0.0§

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§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.