diff options
Diffstat (limited to 'src/errors.rs')
-rw-r--r-- | src/errors.rs | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/src/errors.rs b/src/errors.rs new file mode 100644 index 0000000..be2ca3c --- /dev/null +++ b/src/errors.rs | |||
@@ -0,0 +1,132 @@ | |||
1 | use std::{io, num::TryFromIntError, time::SystemTimeError}; | ||
2 | |||
3 | use chrono::ParseError; | ||
4 | use indicatif::style::TemplateError; | ||
5 | use reqwest::StatusCode; | ||
6 | |||
7 | use crate::db::DBError; | ||
8 | |||
9 | pub type MLE<T> = Result<T, Error>; | ||
10 | |||
11 | #[derive(Debug, thiserror::Error)] | ||
12 | pub enum Error { | ||
13 | #[error("io: {source}")] | ||
14 | Io { | ||
15 | #[from] | ||
16 | source: io::Error, | ||
17 | }, | ||
18 | |||
19 | #[error("tryfromint: {source}")] | ||
20 | TryFromInt { | ||
21 | #[from] | ||
22 | source: TryFromIntError, | ||
23 | }, | ||
24 | |||
25 | #[error("serde_json: {source}")] | ||
26 | Json { | ||
27 | #[from] | ||
28 | source: serde_json::Error, | ||
29 | }, | ||
30 | |||
31 | #[error("reqwest: {source}")] | ||
32 | Reqwest { | ||
33 | #[from] | ||
34 | source: reqwest::Error, | ||
35 | }, | ||
36 | |||
37 | #[error("chrono parse error: {source}")] | ||
38 | ChronoParse { | ||
39 | #[from] | ||
40 | source: ParseError, | ||
41 | }, | ||
42 | |||
43 | #[error("config: {source}")] | ||
44 | Config { | ||
45 | #[from] | ||
46 | source: config::ConfigError, | ||
47 | }, | ||
48 | |||
49 | #[error("indicatif template: {source}")] | ||
50 | IndicatifTemplate { | ||
51 | #[from] | ||
52 | source: TemplateError, | ||
53 | }, | ||
54 | |||
55 | #[error("toml: {source}")] | ||
56 | TomlSer { | ||
57 | #[from] | ||
58 | source: toml::ser::Error, | ||
59 | }, | ||
60 | |||
61 | #[error("toml: {source}")] | ||
62 | TomlDeser { | ||
63 | #[from] | ||
64 | source: toml::de::Error, | ||
65 | }, | ||
66 | |||
67 | #[error("systemtime: {source}")] | ||
68 | Systemtime { | ||
69 | #[from] | ||
70 | source: SystemTimeError, | ||
71 | }, | ||
72 | |||
73 | #[error("conversion: {source}")] | ||
74 | Conversion { | ||
75 | #[from] | ||
76 | source: ConversionError, | ||
77 | }, | ||
78 | |||
79 | #[error("Request didn't return 200 OK ({0})")] | ||
80 | RequestNotOK(StatusCode), | ||
81 | |||
82 | #[error("ModError ({0})")] | ||
83 | ModError(String), | ||
84 | |||
85 | #[error("No file extension where one should be")] | ||
86 | NoFileExtension, | ||
87 | |||
88 | #[error("Desired path not found")] | ||
89 | PathNotFound, | ||
90 | |||
91 | #[error("Desired system directory {0} not found")] | ||
92 | SysDirNotFound(String), | ||
93 | |||
94 | #[error("No requested Minecraft version found")] | ||
95 | MinecraftVersionNotFound, | ||
96 | |||
97 | #[error("Mod already added")] | ||
98 | ModAlreadyOnList, | ||
99 | |||
100 | #[error("No versions are applicable for the current scope")] | ||
101 | NoCurrentVersion, | ||
102 | |||
103 | #[error("The version does not know if it's locked or not")] | ||
104 | VersionSetNotSet, | ||
105 | |||
106 | #[error("No download for the current id found")] | ||
107 | NoDownload, | ||
108 | |||
109 | #[error("No ProjectInfo found / no id given")] | ||
110 | NoProjectInfo, | ||
111 | |||
112 | #[error("The requested List was not found")] | ||
113 | ListNotFound, | ||
114 | |||
115 | #[error("No download folder given")] | ||
116 | NoDownloadFolder, | ||
117 | |||
118 | #[error("db: {source}")] | ||
119 | DB { | ||
120 | #[from] | ||
121 | source: DBError, | ||
122 | }, | ||
123 | } | ||
124 | |||
125 | #[derive(Debug, thiserror::Error)] | ||
126 | pub enum ConversionError { | ||
127 | #[error("couldn't convert to Modloader from: {0}")] | ||
128 | Modloader(String), | ||
129 | |||
130 | #[error("Path couldn't be converted to string")] | ||
131 | InvalidPath, | ||
132 | } | ||