mod display;
use crate::objects::Request;
use super::{
token::tokentype::TokenType,
value::{valuetype::ValueType, Value},
};
pub type EvalResult<T> = Result<T, ErrorType>;
#[derive(Debug)]
pub enum ErrorType {
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 },
}
impl std::error::Error for ErrorType {}