1use crate::value::span::Span;
7
8#[derive(Debug, PartialEq)]
9pub struct Error {
10 pub kind: ErrorKind,
11 pub source: Option<String>,
12 pub span: Span,
13 pub message: String,
14}
15
16impl core::error::Error for Error {}
17
18impl core::fmt::Display for Error {
19 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
20 write!(f, "{self:?}")
21 }
22}
23
24#[derive(Debug, PartialEq)]
25#[non_exhaustive]
26pub enum ErrorKind {
27 Lex,
28 Parse,
29 Eval,
30 Flag,
31 Func,
32 String,
33 Template,
34}
35
36impl core::fmt::Display for ErrorKind {
37 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
38 f.write_str(&format!("{self:?}").to_lowercase())
39 }
40}
41
42impl From<Error> for Span {
43 fn from(value: Error) -> Self {
44 value.span
45 }
46}