1use thiserror::Error;
2
3use crate::Value;
4
5#[allow(clippy::module_name_repetitions)]
8#[derive(Error, Debug, PartialEq)]
9pub enum NativeError {
10 #[error("function \"{0}\" not found")]
11 FunctionNotFound(String),
12 #[error("not enough parameters: \"{0}\" expected")]
13 WrongParameterCount(usize),
14 #[error("wrong parameter type")]
15 WrongParameterType,
16 #[error("index \"{0}\" is out of bounds")]
17 IndexOutOfBounds(usize),
18 #[error("index must not be negative")]
19 IndexNegative,
20 #[error("{0}")]
21 CustomError(String),
22}
23
24impl From<&str> for NativeError {
25 fn from(value: &str) -> Self {
26 Self::CustomError(value.to_string())
27 }
28}
29
30impl From<String> for NativeError {
31 fn from(value: String) -> Self {
32 Self::CustomError(value)
33 }
34}
35
36pub type NativeResult = Result<Value, NativeError>;