pub enum ErrorType {
Show 24 variants TypeError { expected: ValueType, given: ValueType, }, UnknownToken { token: String, }, InvalidTokenPosition { token: TokenType, }, FailedCast { value: Value, from: ValueType, to: ValueType, }, MismatchedArrayLengths { first: usize, second: usize, operation_name: &'static str, }, DivideByZero { numerator: Value, }, NotAnOperator { token: TokenType, }, InvalidClosingBracket, MissingClosingBracket, MissingOperatorArgument { token: TokenType, }, FailedParse { value: String, }, EmptyBrackets, WrongFunctionArgumentsAmount { func_name: String, expected: u8, given: u8, }, MissingFunctionParameters { func_name: String, }, InvalidDeclaration, UnknownFunction { func_name: String, }, UnknownVar { var_name: String, }, ReservedVarName { var_name: String, }, ReservedFunctionName { func_name: String, }, EmptyUnion, InvalidMutableContext { request: Request, }, RecursionDepthLimitReached { limit: u32, }, ErrorDuring { operation_name: &'static str, error: Box<ErrorType>, }, InternalError { message: String, },
}
Expand description

Contains all possible error messages. Implements Display.

use num_parser::*;

let msg = ErrorType::DivideByZero{
    numerator: Value::from(2)
}.to_string();

assert_eq!(msg, "MATH ERROR: trying to divide 2 by zero.");

Variants

TypeError

Fields

expected: ValueType
given: ValueType

A mismatched type.

UnknownToken

Fields

token: String

An unknown token found while parsing the string.

InvalidTokenPosition

Fields

token: TokenType

A known token placed in an invalid position.

FailedCast

Fields

value: Value
from: ValueType

A failed cast due to data loss.

MismatchedArrayLengths

Fields

first: usize
second: usize
operation_name: &'static str

Two arrays with different lengths.

DivideByZero

Fields

numerator: Value

Trying to divide by zero.

NotAnOperator

Fields

token: TokenType

A token which is not an operator being used as such.

InvalidClosingBracket

An invalid closing bracket.

MissingClosingBracket

A missing closing bracket.

MissingOperatorArgument

Fields

token: TokenType

A missing left argument for an operator.

FailedParse

Fields

value: String

An error occurred while parsing a literal.

EmptyBrackets

Two brackets with nothing inside.

WrongFunctionArgumentsAmount

Fields

func_name: String
expected: u8
given: u8

A function call with the wrong function arguments amount.

MissingFunctionParameters

Fields

func_name: String

A function with no parameters.

InvalidDeclaration

An invalid declaration.

UnknownFunction

Fields

func_name: String

An unknown function.

UnknownVar

Fields

var_name: String

An unknown variable.

ReservedVarName

Fields

var_name: String

A reserved variable name.

ReservedFunctionName

Fields

func_name: String

A reserved function name.

EmptyUnion

An empty union ,,

InvalidMutableContext

Fields

request: Request

Invalid request for a static context

RecursionDepthLimitReached

Fields

limit: u32

Reached maximum recursion depth.

ErrorDuring

Fields

operation_name: &'static str
error: Box<ErrorType>

An error wrapper to add additional information.

InternalError

Fields

message: String

An error due to a missing implementation or a bug. This should never occur.

Trait Implementations

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

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

👎 Deprecated since 1.42.0:

use the Display impl or to_string()

👎 Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

🔬 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

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.