diff options
author | fxqnlr <[email protected]> | 2023-01-19 18:37:42 +0100 |
---|---|---|
committer | fxqnlr <[email protected]> | 2023-01-19 18:37:42 +0100 |
commit | f7a6d2e9c67c1fdf8fc17fa0461a201fd2720537 (patch) | |
tree | 21d0c7356b55e9b45517fd9ca874dd3270b6bc3a /src/error.rs | |
parent | be9f74f4fb82b25abd99f7024e0f5eea2691f34f (diff) | |
download | modlist-f7a6d2e9c67c1fdf8fc17fa0461a201fd2720537.tar modlist-f7a6d2e9c67c1fdf8fc17fa0461a201fd2720537.tar.gz modlist-f7a6d2e9c67c1fdf8fc17fa0461a201fd2720537.zip |
input mostly inplemented, mods missing
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/error.rs b/src/error.rs index dbe7224..a1f5f2e 100644 --- a/src/error.rs +++ b/src/error.rs | |||
@@ -15,9 +15,11 @@ pub enum ErrorType { | |||
15 | ArgumentCountError, | 15 | ArgumentCountError, |
16 | ConfigError, | 16 | ConfigError, |
17 | DBError, | 17 | DBError, |
18 | ModError, | ||
18 | LibToml, | 19 | LibToml, |
19 | LibSql, | 20 | LibSql, |
20 | LibReq, | 21 | LibReq, |
22 | LibChrono, | ||
21 | IoError, | 23 | IoError, |
22 | Other, | 24 | Other, |
23 | } | 25 | } |
@@ -31,13 +33,15 @@ impl std::error::Error for MLError { | |||
31 | impl fmt::Display for MLError { | 33 | impl fmt::Display for MLError { |
32 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | 34 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
33 | match self.etype { | 35 | match self.etype { |
34 | ErrorType::ArgumentError => write!(f, "Wrong argument"), | 36 | ErrorType::ArgumentError => write!(f, "User input not accepted: {}", self.message), |
35 | ErrorType::ArgumentCountError => write!(f, "Too many/too few arguments"), | 37 | ErrorType::ArgumentCountError => write!(f, "Too many/too few arguments"), |
36 | ErrorType::ConfigError => write!(f, "CONFIG"), | 38 | ErrorType::ConfigError => write!(f, "CONFIG"), |
37 | ErrorType::DBError => write!(f, "DATABASE"), | 39 | ErrorType::DBError => write!(f, "DATABASE"), |
40 | ErrorType::ModError => write!(f, "Mod: {}", self.message), | ||
38 | ErrorType::LibToml => write!(f, "TOML"), | 41 | ErrorType::LibToml => write!(f, "TOML"), |
39 | ErrorType::LibSql => write!(f, "SQL"), | 42 | ErrorType::LibSql => write!(f, "SQL"), |
40 | ErrorType::LibReq => write!(f, "REQWEST"), | 43 | ErrorType::LibReq => write!(f, "REQWEST"), |
44 | ErrorType::LibChrono => write!(f, "Chrono error: {}", self.message), | ||
41 | ErrorType::IoError => write!(f, "IO"), | 45 | ErrorType::IoError => write!(f, "IO"), |
42 | ErrorType::Other => write!(f, "OTHER") | 46 | ErrorType::Other => write!(f, "OTHER") |
43 | } | 47 | } |
@@ -68,6 +72,12 @@ impl From<toml::ser::Error> for MLError { | |||
68 | } | 72 | } |
69 | } | 73 | } |
70 | 74 | ||
75 | impl From<chrono::ParseError> for MLError { | ||
76 | fn from(error: chrono::ParseError) -> Self { | ||
77 | Self { etype: ErrorType::LibChrono, message: error.to_string() } | ||
78 | } | ||
79 | } | ||
80 | |||
71 | impl From<std::io::Error> for MLError { | 81 | impl From<std::io::Error> for MLError { |
72 | fn from(error: std::io::Error) -> Self { | 82 | fn from(error: std::io::Error) -> Self { |
73 | Self { etype: ErrorType::IoError, message: error.to_string() } | 83 | Self { etype: ErrorType::IoError, message: error.to_string() } |