1use std::fmt;
2
3#[derive(Debug)]
4pub enum ErrorType {
5 IllegalCharacterError,
6 SyntaxError,
7}
8
9#[derive(Debug)]
10pub struct Error {
11 pub error_type: ErrorType,
12 pub description: String,
13}
14
15impl fmt::Display for ErrorType {
16 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17 match self {
18 ErrorType::IllegalCharacterError => write!(f, "IllegalCharacterError"),
19 ErrorType::SyntaxError => write!(f, "SyntaxError"),
20 }
21 }
22}
23
24impl fmt::Display for Error {
25 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26 write!(f, "{}: {}", self.error_type, self.description)
27 }
28}