diff options
author | fxqnlr <[email protected]> | 2022-11-17 21:20:09 +0100 |
---|---|---|
committer | fxqnlr <[email protected]> | 2022-11-17 21:20:09 +0100 |
commit | fdd7525e5a0d298ebb8a9aa81cc19ec79e8cd113 (patch) | |
tree | ec7c7c80434b339f9442882f1e2dce6f60cc9edd /src/error.rs | |
parent | 5145dd23f1777180d8003e76f59af57643796516 (diff) | |
download | modlist-fdd7525e5a0d298ebb8a9aa81cc19ec79e8cd113.tar modlist-fdd7525e5a0d298ebb8a9aa81cc19ec79e8cd113.tar.gz modlist-fdd7525e5a0d298ebb8a9aa81cc19ec79e8cd113.zip |
added --clean for update && list downloadfolder
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..c82688c --- /dev/null +++ b/src/error.rs | |||
@@ -0,0 +1,34 @@ | |||
1 | use core::fmt; | ||
2 | |||
3 | pub type MLE<T> = Result<T, MLError>; | ||
4 | |||
5 | #[derive(Debug)] | ||
6 | pub struct MLError { | ||
7 | etype: ErrorType, | ||
8 | message: String, | ||
9 | } | ||
10 | |||
11 | #[derive(Debug)] | ||
12 | pub enum ErrorType { | ||
13 | ArgumentError | ||
14 | } | ||
15 | |||
16 | impl std::error::Error for MLError { | ||
17 | fn description(&self) -> &str { | ||
18 | &self.message | ||
19 | } | ||
20 | } | ||
21 | |||
22 | impl fmt::Display for MLError { | ||
23 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
24 | match self.etype { | ||
25 | ErrorType::ArgumentError => write!(f, "ARGS") | ||
26 | } | ||
27 | } | ||
28 | } | ||
29 | |||
30 | impl MLError { | ||
31 | pub fn new(etype: ErrorType, message: &str) -> Self { | ||
32 | Self { etype, message: String::from(message) } | ||
33 | } | ||
34 | } | ||