use core::fmt::{self, Display, Formatter};
use stak_primitive::SmallError;
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum CompileError {
Run(SmallError),
User(String),
Vm(stak_vm::Error),
}
impl std::error::Error for CompileError {}
impl Display for CompileError {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
match self {
Self::Run(error) => write!(formatter, "{error}"),
Self::User(error) => write!(formatter, "{error}"),
Self::Vm(error) => write!(formatter, "{error}"),
}
}
}
impl From<SmallError> for CompileError {
fn from(error: SmallError) -> Self {
Self::Run(error)
}
}
impl From<stak_vm::Error> for CompileError {
fn from(error: stak_vm::Error) -> Self {
Self::Vm(error)
}
}