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] reqwest::Error),
25    #[error("Can't find file: {0}")]
26    InvalidPath(String),
27
28    #[error("Unexpected template problem: {0}")]
29    TemplateProblem(#[from] askama::Error),
30
31    #[error("Fatal error: {0}")]
32    Fatal(#[from] anyhow::Error),
33
34    #[error("Internal error: {0}")]
35    InternalError(&'static str),
36    #[error("Validation Error at {0}: {1}")]
37    ValidationError(String, String),
38    #[error("Type Parsing Error: {0}")]
39    TypeParsingError(String),
40    #[error("Invalid Channel error: The channel `{0}` is specified, but only {1:?} are supported for the file")]
41    InvalidChannelError(String, Vec<String>),
42
43    #[error("Problem with {0}: {1}")]
44    FMLModuleError(ModuleId, String),
45
46    #[error("{0}")]
47    CliError(String),
48
49    #[cfg(feature = "client-lib")]
50    #[error("{0}")]
51    ClientError(#[from] ClientError),
52
53    #[error("Feature `{0}` not found on manifest")]
54    InvalidFeatureError(String),
55
56    #[error("Invalid API token GITHUB_BEARER_TOKEN")]
57    InvalidApiToken,
58}
59
60#[cfg(feature = "client-lib")]
61#[derive(Debug, thiserror::Error)]
62pub enum ClientError {
63    #[error("{0}")]
64    InvalidFeatureConfig(String),
65    #[error("{0}")]
66    InvalidFeatureId(String),
67    #[error("{0}")]
68    InvalidFeatureValue(String),
69    #[error("{0}")]
70    JsonMergeError(String),
71}
72
73pub type Result<T, E = FMLError> = std::result::Result<T, E>;