formatic/
error.rs

1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
4pub enum ObjectError {
5    DeclWithoutSymbol,
6    UnknownFunction(String),
7    UnknownTargetSymbol(String),
8}
9
10impl fmt::Display for ObjectError {
11    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
12        let str = match self {
13            ObjectError::DeclWithoutSymbol => "got decleration without symbol".to_string(),
14            ObjectError::UnknownFunction(n) => format!("unknown function {}", n),
15            ObjectError::UnknownTargetSymbol(n) => format!("unknown target symbol {}", n),
16        };
17
18        write!(f, "{}", str)
19    }
20}
21
22impl std::error::Error for ObjectError {}