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
A mismatched type.
UnknownToken
An unknown token found while parsing the string.
InvalidTokenPosition
A known token placed in an invalid position.
Fields
token: TokenType
FailedCast
A failed cast due to data loss.
MismatchedArrayLengths
Two arrays with different lengths.
DivideByZero
Trying to divide by zero.
NotAnOperator
A token which is not an operator being used as such.
Fields
token: TokenType
InvalidClosingBracket
An invalid closing bracket.
MissingClosingBracket
A missing closing bracket.
MissingOperatorArgument
A missing left argument for an operator.
Fields
token: TokenType
FailedParse
An error occurred while parsing a literal.
EmptyBrackets
Two brackets with nothing inside.
WrongFunctionArgumentsAmount
A function call with the wrong function arguments amount.
MissingFunctionParameters
A function with no parameters.
InvalidDeclaration
An invalid declaration.
UnknownFunction
An unknown function.
UnknownVar
An unknown variable.
ReservedVarName
A reserved variable name.
ReservedFunctionName
A reserved function name.
EmptyUnion
An empty union ,,
InvalidMutableContext
Invalid request for a static context
Fields
request: Request
RecursionDepthLimitReached
Reached maximum recursion depth.
ErrorDuring
An error wrapper to add additional information.
InternalError
An error due to a missing implementation or a bug. This should never occur.
Trait Implementations§
Source§impl Error for ErrorType
impl Error for ErrorType
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Auto Trait Implementations§
impl Freeze for ErrorType
impl RefUnwindSafe for ErrorType
impl Send for ErrorType
impl Sync for ErrorType
impl Unpin for ErrorType
impl UnwindSafe for ErrorType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more