#[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.
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.
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.
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
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
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.
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§
Trait Implementations§
Source§impl From<ParseFloatError> for ExprError
impl From<ParseFloatError> for ExprError
Source§fn from(err: ParseFloatError) -> ExprError
fn from(err: ParseFloatError) -> ExprError
Auto Trait Implementations§
impl Freeze for ExprError
impl RefUnwindSafe for ExprError
impl Send for ExprError
impl Sync for ExprError
impl Unpin for ExprError
impl UnwindSafe for ExprError
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)