1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use std::error::Error;
use std::fmt;
#[derive(Debug, PartialEq)]
pub enum SMTError {
APIError(String),
UnsupportedError(String),
InternalError(String),
}
use SMTError::*;
impl SMTError {
pub fn new_api(msg: &str) -> SMTError {
APIError(msg.to_string())
}
pub fn new_unsupported(msg: &str) -> SMTError {
UnsupportedError(msg.to_string())
}
pub fn new_internal(msg: &str) -> SMTError {
InternalError(msg.to_string())
}
}
impl fmt::Display for SMTError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let message = match self {
APIError(s) => s,
UnsupportedError(s) => s,
InternalError(s) => s,
};
write!(f, "{}", message)
}
}
impl Error for SMTError {
fn description(&self) -> &str {
match self {
APIError(s) => s,
UnsupportedError(s) => s,
InternalError(s) => s,
}
}
}