diff options
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs index bd6e3da..e6afeaa 100644 --- a/src/error.rs +++ b/src/error.rs | |||
@@ -20,6 +20,7 @@ pub enum ErrorType { | |||
20 | LibSql, | 20 | LibSql, |
21 | LibReq, | 21 | LibReq, |
22 | LibChrono, | 22 | LibChrono, |
23 | LibJson, | ||
23 | IoError, | 24 | IoError, |
24 | Other, | 25 | Other, |
25 | } | 26 | } |
@@ -42,6 +43,7 @@ impl fmt::Display for MLError { | |||
42 | ErrorType::LibSql => write!(f, "SQL: {}", self.message), | 43 | ErrorType::LibSql => write!(f, "SQL: {}", self.message), |
43 | ErrorType::LibReq => write!(f, "REQWEST"), | 44 | ErrorType::LibReq => write!(f, "REQWEST"), |
44 | ErrorType::LibChrono => write!(f, "Chrono error: {}", self.message), | 45 | ErrorType::LibChrono => write!(f, "Chrono error: {}", self.message), |
46 | ErrorType::LibJson => write!(f, "JSON: {}", self.message), | ||
45 | ErrorType::IoError => write!(f, "IO"), | 47 | ErrorType::IoError => write!(f, "IO"), |
46 | ErrorType::Other => write!(f, "OTHER"), | 48 | ErrorType::Other => write!(f, "OTHER"), |
47 | } | 49 | } |
@@ -102,6 +104,13 @@ impl From<std::io::Error> for MLError { | |||
102 | } | 104 | } |
103 | } | 105 | } |
104 | 106 | ||
107 | impl From<serde_json::error::Error> for MLError { | ||
108 | fn from(value: serde_json::error::Error) -> Self { | ||
109 | Self { etype: ErrorType::LibJson, message: value.to_string() } | ||
110 | } | ||
111 | |||
112 | } | ||
113 | |||
105 | impl MLError { | 114 | impl MLError { |
106 | pub fn new(etype: ErrorType, message: &str) -> Self { | 115 | pub fn new(etype: ErrorType, message: &str) -> Self { |
107 | Self { | 116 | Self { |