summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2023-01-09 23:12:52 +0100
committerfxqnlr <[email protected]>2023-01-09 23:12:52 +0100
commit89193143f90e1b8cbb91445d14942fa39509acbb (patch)
tree4aeb60ae2aceffc2468589c615ead9dc7079a34d /src/error.rs
parent94d7656cce4ca751be545eeb2ff52bdea1f37fa0 (diff)
downloadmodlist-89193143f90e1b8cbb91445d14942fa39509acbb.tar
modlist-89193143f90e1b8cbb91445d14942fa39509acbb.tar.gz
modlist-89193143f90e1b8cbb91445d14942fa39509acbb.zip
implemented more Error (dumb)
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/error.rs b/src/error.rs
index 192aa76..dbe7224 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -14,8 +14,12 @@ pub enum ErrorType {
14 ArgumentError, 14 ArgumentError,
15 ArgumentCountError, 15 ArgumentCountError,
16 ConfigError, 16 ConfigError,
17 DBError,
17 LibToml, 18 LibToml,
19 LibSql,
20 LibReq,
18 IoError, 21 IoError,
22 Other,
19} 23}
20 24
21impl std::error::Error for MLError { 25impl std::error::Error for MLError {
@@ -30,18 +34,34 @@ impl fmt::Display for MLError {
30 ErrorType::ArgumentError => write!(f, "Wrong argument"), 34 ErrorType::ArgumentError => write!(f, "Wrong argument"),
31 ErrorType::ArgumentCountError => write!(f, "Too many/too few arguments"), 35 ErrorType::ArgumentCountError => write!(f, "Too many/too few arguments"),
32 ErrorType::ConfigError => write!(f, "CONFIG"), 36 ErrorType::ConfigError => write!(f, "CONFIG"),
37 ErrorType::DBError => write!(f, "DATABASE"),
33 ErrorType::LibToml => write!(f, "TOML"), 38 ErrorType::LibToml => write!(f, "TOML"),
34 ErrorType::IoError => write!(f, "IO") 39 ErrorType::LibSql => write!(f, "SQL"),
40 ErrorType::LibReq => write!(f, "REQWEST"),
41 ErrorType::IoError => write!(f, "IO"),
42 ErrorType::Other => write!(f, "OTHER")
35 } 43 }
36 } 44 }
37} 45}
38 46
47impl From<reqwest::Error> for MLError {
48 fn from(error: reqwest::Error) -> Self {
49 Self { etype: ErrorType::LibReq, message: error.to_string() }
50 }
51}
52
39impl From<toml::de::Error> for MLError { 53impl From<toml::de::Error> for MLError {
40 fn from(error: toml::de::Error) -> Self { 54 fn from(error: toml::de::Error) -> Self {
41 Self { etype: ErrorType::LibToml, message: error.to_string() } 55 Self { etype: ErrorType::LibToml, message: error.to_string() }
42 } 56 }
43} 57}
44 58
59impl From<rusqlite::Error> for MLError {
60 fn from(error: rusqlite::Error) -> Self {
61 Self { etype: ErrorType::LibSql, message: error.to_string() }
62 }
63}
64
45impl From<toml::ser::Error> for MLError { 65impl From<toml::ser::Error> for MLError {
46 fn from(error: toml::ser::Error) -> Self { 66 fn from(error: toml::ser::Error) -> Self {
47 Self { etype: ErrorType::LibToml, message: error.to_string() } 67 Self { etype: ErrorType::LibToml, message: error.to_string() }