use thiserror::Error;
pub type Result<T> = std::result::Result<T, LambdustError>;
#[derive(Error, Debug, Clone, PartialEq)]
pub enum LambdustError {
#[error("Lexer error: {0}")]
LexerError(String),
#[error("Parse error: {0}")]
ParseError(String),
#[error("Runtime error: {0}")]
RuntimeError(String),
#[error("Type error: {0}")]
TypeError(String),
#[error("Undefined variable: {0}")]
UndefinedVariable(String),
#[error("Arity error: expected {expected}, got {actual}")]
ArityError {
expected: usize,
actual: usize
},
#[error("Division by zero")]
DivisionByZero,
#[error("I/O error: {0}")]
IoError(String),
#[error("Stack overflow")]
StackOverflow,
#[error("Macro error: {0}")]
MacroError(String),
#[error("Syntax error: {0}")]
SyntaxError(String),
}
impl From<std::io::Error> for LambdustError {
fn from(err: std::io::Error) -> Self {
LambdustError::IoError(err.to_string())
}
}