use core::{
error,
fmt::{self, Display, Formatter},
};
#[derive(Debug)]
pub enum DynamicError {
Downcast,
ObjectIndex,
Vm(stak_vm::Error),
}
impl From<stak_vm::Error> for DynamicError {
fn from(error: stak_vm::Error) -> Self {
Self::Vm(error)
}
}
impl error::Error for DynamicError {}
impl Display for DynamicError {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
match self {
Self::Downcast => write!(formatter, "cannot downcast object"),
Self::ObjectIndex => write!(formatter, "invalid object index"),
Self::Vm(error) => write!(formatter, "{error}"),
}
}
}