1use std::{error, fmt};
2
3#[derive(Debug)]
5pub struct Error {
6 kind: ErrorKind,
7}
8
9#[derive(Debug)]
11pub enum ErrorKind {
12 Expression(String),
14}
15
16impl fmt::Display for Error {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18 match self.kind {
19 ErrorKind::Expression(ref expr) => write!(f, "Invalid expression: {}", expr),
20 }
21 }
22}
23
24impl error::Error for Error {}
25
26impl From<ErrorKind> for Error {
27 fn from(kind: ErrorKind) -> Error {
28 Error { kind }
29 }
30}