summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2023-04-20 15:13:58 +0200
committerfxqnlr <[email protected]>2023-04-20 15:13:58 +0200
commit8050cfcd70a16273cc2814fe29c8ee08320d85d3 (patch)
tree13924a7f1a9a0c7515beb47a14fe62d5c387d09a /src/error.rs
parentfde646a876cc43857a278ef09250263a21d547ee (diff)
downloadmodlist-8050cfcd70a16273cc2814fe29c8ee08320d85d3.tar
modlist-8050cfcd70a16273cc2814fe29c8ee08320d85d3.tar.gz
modlist-8050cfcd70a16273cc2814fe29c8ee08320d85d3.zip
cargo fmt
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}