1use thiserror::Error;
5
6#[derive(Debug, Error)]
7pub enum EvalError {
8 #[error("unbound identifier: {0}")]
9 Unbound(String),
10
11 #[error("type error: expected {expected}, got {found}")]
12 Type { expected: String, found: String },
13
14 #[error("arity error: {name} expects {expected} args, got {got}")]
15 Arity {
16 name: String,
17 expected: String,
18 got: usize,
19 },
20
21 #[error("malformed special form `{form}`: {reason}")]
22 Malformed { form: String, reason: String },
23
24 #[error("unknown builtin: {0}")]
25 UnknownBuiltin(String),
26
27 #[error("division by zero")]
28 DivByZero,
29
30 #[error("derivation error: {0}")]
31 Derivation(String),
32
33 #[error("attribute `{0}` not present")]
34 MissingAttr(String),
35
36 #[error("io error: {0}")]
37 Io(#[from] std::io::Error),
38
39 #[error(transparent)]
40 Lisp(#[from] tatara_lisp::LispError),
41
42 #[error("other: {0}")]
43 Other(String),
44}
45
46pub type Result<T> = std::result::Result<T, EvalError>;