nimbus_fml/
error.rs

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