-
Notifications
You must be signed in to change notification settings - Fork 221
/
error.rs
68 lines (57 loc) · 2.02 KB
/
error.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* */
use crate::intermediate_representation::ModuleId;
#[derive(Debug, thiserror::Error)]
pub enum FMLError {
#[error("IO error: {0}")]
IOError(#[from] std::io::Error),
#[error("JSON Error: {0}")]
JSONError(#[from] serde_json::Error),
#[error("YAML Error: {0}")]
YAMLError(#[from] serde_yaml::Error),
#[error("URL Error: {0}")]
UrlError(#[from] url::ParseError),
#[error("Fetch Error: {0}")]
FetchError(#[from] reqwest::Error),
#[error("Can't find file: {0}")]
InvalidPath(String),
#[error("Unexpected template problem: {0}")]
TemplateProblem(#[from] askama::Error),
#[error("Fatal error: {0}")]
Fatal(#[from] anyhow::Error),
#[allow(dead_code)]
#[error("Internal error: {0}")]
InternalError(&'static str),
#[error("Validation Error at {0}: {1}")]
ValidationError(String, String),
#[error("Type Parsing Error: {0}")]
TypeParsingError(String),
#[error("Invalid Channel error: The channel `{0}` is specified, but only {1:?} are supported for the file")]
InvalidChannelError(String, Vec<String>),
#[error("Problem with {0}: {1}")]
FMLModuleError(ModuleId, String),
#[error("{0}")]
CliError(String),
#[cfg(feature = "client-lib")]
#[error("{0}")]
ClientError(#[from] ClientError),
#[error("Feature `{0}` not found on manifest")]
InvalidFeatureError(String),
#[error("Property `{0}` not found on feature `{1}`")]
InvalidPropertyError(String, String),
}
#[cfg(feature = "client-lib")]
#[derive(Debug, thiserror::Error)]
pub enum ClientError {
#[error("{0}")]
InvalidFeatureConfig(String),
#[error("{0}")]
InvalidFeatureId(String),
#[error("{0}")]
InvalidFeatureValue(String),
#[error("{0}")]
JsonMergeError(String),
}
pub type Result<T, E = FMLError> = std::result::Result<T, E>;