Enum arithmetic_eval::error::ErrorKind
source · #[non_exhaustive]pub enum ErrorKind {
Show 20 variants
TupleLenMismatch {
lhs: LvalueLen,
rhs: usize,
context: TupleLenMismatchContext,
},
FieldsMismatch {
lhs_fields: HashSet<String>,
rhs_fields: HashSet<String>,
op: BinaryOp,
},
ArgsLenMismatch {
def: LvalueLen,
call: usize,
},
CannotDestructure,
RepeatedAssignment {
context: RepeatedAssignmentContext,
},
RepeatedField,
Undefined(String),
Uninitialized(String),
InvalidFieldName(String),
CannotCall,
CannotIndex,
CannotAccessFields,
IndexOutOfBounds {
index: usize,
len: usize,
},
NoField {
field: String,
available_fields: Vec<String>,
},
NativeCall(String),
Wrapper(FromValueError),
UnexpectedOperand {
op: Op,
},
CannotCompare,
Unsupported(UnsupportedType),
Arithmetic(ArithmeticError),
}
Expand description
Kinds of errors that can occur when compiling or interpreting expressions and statements.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
TupleLenMismatch
Fields
context: TupleLenMismatchContext
Context in which the error has occurred.
Mismatch between length of tuples in a binary operation or assignment.
FieldsMismatch
Fields
Field set differs between LHS and RHS, which are both objects.
ArgsLenMismatch
Fields
Mismatch between the number of arguments in the function definition and its call.
CannotDestructure
Cannot destructure a non-tuple variable.
RepeatedAssignment
Fields
context: RepeatedAssignmentContext
Context in which the error has occurred.
Repeated assignment to the same variable in function args or tuple destructuring.
RepeatedField
Repeated field in object initialization (e.g., #{ x: 1, x: 2 }
) or destructure
(e.g., { x, x }
).
Undefined(String)
Variable with the enclosed name is not defined.
Uninitialized(String)
Variable is not initialized.
InvalidFieldName(String)
Field name is invalid.
CannotCall
Value is not callable (i.e., it is not a function).
CannotIndex
Value cannot be indexed (i.e., it is not a tuple).
CannotAccessFields
A field cannot be accessed for the value (i.e., it is not an object).
IndexOutOfBounds
Index is out of bounds for the indexed tuple.
NoField
Fields
Object does not have a required field.
NativeCall(String)
Generic error during execution of a native function.
Wrapper(FromValueError)
Error while converting arguments for FnWrapper
.
UnexpectedOperand
Unexpected operand type for the specified operation.
CannotCompare
Value cannot be compared to other values. Only primitive values can be compared; other value types cannot.
Unsupported(UnsupportedType)
Construct not supported by the interpreter.
Arithmetic(ArithmeticError)
Arithmetic
error, such as division by zero.
Implementations§
source§impl ErrorKind
impl ErrorKind
sourcepub fn unsupported<T: Into<UnsupportedType>>(ty: T) -> Self
pub fn unsupported<T: Into<UnsupportedType>>(ty: T) -> Self
Creates an error for an lvalue type not supported by the interpreter.
sourcepub fn to_short_string(&self) -> String
pub fn to_short_string(&self) -> String
Returned shortened error cause.
sourcepub fn main_span_info(&self) -> String
pub fn main_span_info(&self) -> String
Returns a short description of the spanned information.