use crate::value::span::Span;
#[derive(Debug, PartialEq)]
pub struct Error {
pub kind: ErrorKind,
pub source: Option<String>,
pub span: Span,
pub message: String,
}
impl core::error::Error for Error {}
impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{self:?}")
}
}
#[derive(Debug, PartialEq)]
#[non_exhaustive]
pub enum ErrorKind {
Lex,
Parse,
Eval,
Flag,
Func,
String,
Template,
}
impl core::fmt::Display for ErrorKind {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_str(&format!("{self:?}").to_lowercase())
}
}
impl From<Error> for Span {
fn from(value: Error) -> Self {
value.span
}
}