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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

TupleLenMismatch

Mismatch between length of tuples in a binary operation or assignment.

Fields

§lhs: LvalueLen

Length of a tuple on the left-hand side.

§rhs: usize

Length of a tuple on the right-hand side.

§context: TupleLenMismatchContext

Context in which the error has occurred.

§

FieldsMismatch

Field set differs between LHS and RHS, which are both objects.

Fields

§lhs_fields: HashSet<String>

Fields in LHS.

§rhs_fields: HashSet<String>

Fields in RHS.

§op: BinaryOp

Operation being performed.

§

ArgsLenMismatch

Mismatch between the number of arguments in the function definition and its call.

Fields

§def: LvalueLen

Number of args at the function definition.

§call: usize

Number of args at the function call.

§

CannotDestructure

Cannot destructure a non-tuple variable.

§

RepeatedAssignment

Repeated assignment to the same variable in function args or tuple destructuring.

Fields

§context: RepeatedAssignmentContext

Context in which the error has occurred.

§

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.

Fields

§index: usize

Index.

§len: usize

Actual tuple length.

§

NoField

Object does not have a required field.

Fields

§field: String

Missing field.

§available_fields: Vec<String>

Available fields in the object in no particular order.

§

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.

Fields

§op: Op

Operation which failed.

§

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

source

pub fn native(message: impl Into<String>) -> Self

Creates a native error.

source

pub fn unsupported<T: Into<UnsupportedType>>(ty: T) -> Self

Creates an error for an lvalue type not supported by the interpreter.

source

pub fn to_short_string(&self) -> String

Returned shortened error cause.

source

pub fn main_span_info(&self) -> String

Returns a short description of the spanned information.

source

pub fn help(&self) -> Option<String>

Returns information helping fix the error.

Trait Implementations§

source§

impl Debug for ErrorKind

source§

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

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

impl Display for ErrorKind

source§

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

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

impl Error for ErrorKind

source§

fn source(&self) -> Option<&(dyn Error + 'static)>

The lower-level source of this error, if any. Read more
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more

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> 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> ToString for T
where T: Display + ?Sized,

source§

default 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>,

§

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

§

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.