summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorfx <[email protected]>2023-05-04 14:33:23 +0200
committerfx <[email protected]>2023-05-04 14:33:23 +0200
commit0c7ba29d3e17c47e5fc9cffe78c28a0019d453b7 (patch)
tree1815f82eaa9e84f8f73683a84ed99063e4e0d904 /src/error.rs
parent2b180daf1e2687436046b853c59e0abe12c50f57 (diff)
parent59d539f756375719f7ff71822c72afa00c3bd3c4 (diff)
downloadmodlist-0c7ba29d3e17c47e5fc9cffe78c28a0019d453b7.tar
modlist-0c7ba29d3e17c47e5fc9cffe78c28a0019d453b7.tar.gz
modlist-0c7ba29d3e17c47e5fc9cffe78c28a0019d453b7.zip
Merge pull request 'config' (#4) from config into master
Reviewed-on: http://raspberrypi.fritz.box:7920/fx/modlist/pulls/4
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs9
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
107impl 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
105impl MLError { 114impl MLError {
106 pub fn new(etype: ErrorType, message: &str) -> Self { 115 pub fn new(etype: ErrorType, message: &str) -> Self {
107 Self { 116 Self {