use core::{
error::Error,
fmt::{self, Display, Formatter},
};
use stak_dynamic::DynamicError;
use stak_r7rs::SmallError;
#[derive(Debug)]
pub enum EngineError {
Dynamic(DynamicError),
Small(SmallError),
Vm(stak_vm::Error),
}
impl From<DynamicError> for EngineError {
fn from(error: DynamicError) -> Self {
Self::Dynamic(error)
}
}
impl From<SmallError> for EngineError {
fn from(error: SmallError) -> Self {
Self::Small(error)
}
}
impl From<stak_vm::Error> for EngineError {
fn from(error: stak_vm::Error) -> Self {
Self::Vm(error)
}
}
impl Error for EngineError {}
impl Display for EngineError {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
match self {
Self::Dynamic(error) => write!(formatter, "{error}"),
Self::Small(error) => write!(formatter, "{error}"),
Self::Vm(error) => write!(formatter, "{error}"),
}
}
}