use thiserror::Error;
use crate::ConstString;
#[derive(Error, Debug)]
pub enum ExecutionError {
#[error("boolean values do not allow arithmetic operations")]
BoolNoArithmetic,
#[error("environment error: {0}")]
Environment(#[from] crate::environment::Error),
#[error("value is 'Nil' which does not allow any operation")]
NilValue,
#[error("expected boolean ('true'/'false'), got {value}")]
NoBoolean {
value: ConstString,
},
#[error("comparing values needs two numeric types")]
NoComparison,
#[error("expected integer value, got {value}")]
NoInteger {
value: ConstString,
},
#[error("expected numerical value, got {value}")]
NoNumber {
value: ConstString,
},
#[error("stack overflow, to many variables/values")]
StackOverflow,
#[error("to Strings you can only 'ADD' something")]
OnlyAdd,
#[error("{file} at line {line} should be unreachable")]
Unreachable {
file: ConstString,
line: u32,
},
}
#[cfg(test)]
mod tests {
use super::*;
const fn is_normal<T: Sized + Send + Sync>() {}
#[test]
const fn normal_types() {
is_normal::<&ExecutionError>();
is_normal::<ExecutionError>();
}
}