aboutsummaryrefslogtreecommitdiffstats
path: root/src/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/errors.rs')
-rw-r--r--src/errors.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/errors.rs b/src/errors.rs
new file mode 100644
index 0000000..c167733
--- /dev/null
+++ b/src/errors.rs
@@ -0,0 +1,34 @@
1use std::{fmt, io};
2
3#[allow(dead_code)]
4#[derive(Debug)]
5pub enum McError {
6 Io(io::Error),
7 Http(reqwest::Error),
8 Json(serde_json::Error),
9 Zip(zip::result::ZipError),
10 Config(String),
11 ShaMismatch(String),
12 Process(String),
13 Runtime(String), // ← NEW
14}
15
16impl fmt::Display for McError {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self) }
18}
19
20impl From<io::Error> for McError {
21 fn from(e: io::Error) -> Self { Self::Io(e) }
22}
23
24impl From<reqwest::Error> for McError {
25 fn from(e: reqwest::Error) -> Self { Self::Http(e) }
26}
27
28impl From<serde_json::Error> for McError {
29 fn from(e: serde_json::Error) -> Self { Self::Json(e) }
30}
31
32impl From<zip::result::ZipError> for McError {
33 fn from(e: zip::result::ZipError) -> Self { Self::Zip(e) }
34}