summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorfx <[email protected]>2023-04-23 14:13:03 +0200
committerfx <[email protected]>2023-04-23 14:13:03 +0200
commit4300ad2eb05dddfa4274e04b204f2ad28c87da05 (patch)
treea2fd059e3aefff812d0d25e23fc85203dc9d122a /src/error.rs
parent2711f05669e353fbf452156d54855e9ba454f4a8 (diff)
parent64958cc9ff0858dbf068625e35b8d5dae249d4a4 (diff)
downloadmodlist-4300ad2eb05dddfa4274e04b204f2ad28c87da05.tar
modlist-4300ad2eb05dddfa4274e04b204f2ad28c87da05.tar.gz
modlist-4300ad2eb05dddfa4274e04b204f2ad28c87da05.zip
Merge pull request 'clap' (#1) from clap into master
Reviewed-on: http://raspberrypi.fritz.box:7920/fx/modlist/pulls/1
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs37
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
51impl From<reqwest::Error> for MLError { 51impl 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
57impl From<toml::de::Error> for MLError { 60impl 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
63impl From<rusqlite::Error> for MLError { 69impl 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
69impl From<toml::ser::Error> for MLError { 78impl 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
75impl From<chrono::ParseError> for MLError { 87impl 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
81impl From<std::io::Error> for MLError { 96impl 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
87impl MLError { 105impl 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}