diff options
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/src/error.rs b/src/error.rs index 794a919..bd6e3da 100644 --- a/src/error.rs +++ b/src/error.rs | |||
@@ -43,49 +43,70 @@ impl fmt::Display for MLError { | |||
43 | ErrorType::LibReq => write!(f, "REQWEST"), | 43 | ErrorType::LibReq => write!(f, "REQWEST"), |
44 | ErrorType::LibChrono => write!(f, "Chrono error: {}", self.message), | 44 | ErrorType::LibChrono => write!(f, "Chrono error: {}", self.message), |
45 | ErrorType::IoError => write!(f, "IO"), | 45 | ErrorType::IoError => write!(f, "IO"), |
46 | ErrorType::Other => write!(f, "OTHER") | 46 | ErrorType::Other => write!(f, "OTHER"), |
47 | } | 47 | } |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | impl From<reqwest::Error> for MLError { | 51 | impl From<reqwest::Error> for MLError { |
52 | fn from(error: reqwest::Error) -> Self { | 52 | fn from(error: reqwest::Error) -> Self { |
53 | Self { etype: ErrorType::LibReq, message: error.to_string() } | 53 | Self { |
54 | etype: ErrorType::LibReq, | ||
55 | message: error.to_string(), | ||
56 | } | ||
54 | } | 57 | } |
55 | } | 58 | } |
56 | 59 | ||
57 | impl From<toml::de::Error> for MLError { | 60 | impl From<toml::de::Error> for MLError { |
58 | fn from(error: toml::de::Error) -> Self { | 61 | fn from(error: toml::de::Error) -> Self { |
59 | Self { etype: ErrorType::LibToml, message: error.to_string() } | 62 | Self { |
63 | etype: ErrorType::LibToml, | ||
64 | message: error.to_string(), | ||
65 | } | ||
60 | } | 66 | } |
61 | } | 67 | } |
62 | 68 | ||
63 | impl From<rusqlite::Error> for MLError { | 69 | impl From<rusqlite::Error> for MLError { |
64 | fn from(error: rusqlite::Error) -> Self { | 70 | fn from(error: rusqlite::Error) -> Self { |
65 | Self { etype: ErrorType::LibSql, message: error.to_string() } | 71 | Self { |
72 | etype: ErrorType::LibSql, | ||
73 | message: error.to_string(), | ||
74 | } | ||
66 | } | 75 | } |
67 | } | 76 | } |
68 | 77 | ||
69 | impl From<toml::ser::Error> for MLError { | 78 | impl From<toml::ser::Error> for MLError { |
70 | fn from(error: toml::ser::Error) -> Self { | 79 | fn from(error: toml::ser::Error) -> Self { |
71 | Self { etype: ErrorType::LibToml, message: error.to_string() } | 80 | Self { |
81 | etype: ErrorType::LibToml, | ||
82 | message: error.to_string(), | ||
83 | } | ||
72 | } | 84 | } |
73 | } | 85 | } |
74 | 86 | ||
75 | impl From<chrono::ParseError> for MLError { | 87 | impl From<chrono::ParseError> for MLError { |
76 | fn from(error: chrono::ParseError) -> Self { | 88 | fn from(error: chrono::ParseError) -> Self { |
77 | Self { etype: ErrorType::LibChrono, message: error.to_string() } | 89 | Self { |
90 | etype: ErrorType::LibChrono, | ||
91 | message: error.to_string(), | ||
92 | } | ||
78 | } | 93 | } |
79 | } | 94 | } |
80 | 95 | ||
81 | impl From<std::io::Error> for MLError { | 96 | impl From<std::io::Error> for MLError { |
82 | fn from(error: std::io::Error) -> Self { | 97 | fn from(error: std::io::Error) -> Self { |
83 | Self { etype: ErrorType::IoError, message: error.to_string() } | 98 | Self { |
99 | etype: ErrorType::IoError, | ||
100 | message: error.to_string(), | ||
101 | } | ||
84 | } | 102 | } |
85 | } | 103 | } |
86 | 104 | ||
87 | impl MLError { | 105 | impl MLError { |
88 | pub fn new(etype: ErrorType, message: &str) -> Self { | 106 | pub fn new(etype: ErrorType, message: &str) -> Self { |
89 | Self { etype, message: String::from(message) } | 107 | Self { |
108 | etype, | ||
109 | message: String::from(message), | ||
110 | } | ||
90 | } | 111 | } |
91 | } | 112 | } |