1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
use std::error::Error; use std::fmt; #[derive(Debug, Clone)] pub enum LexerError { InternalError, UnexpectedCharakter, } impl fmt::Display for LexerError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.description()) } } impl Error for LexerError { fn description(&self) -> &str { match *self { LexerError::InternalError => "An internal error was found during the lexer phase. please report this error to TODO(romankl) github url", LexerError::UnexpectedCharakter => "An unexpected charater was found. fix this error to pass the lexer phase" } } }