bulwark_config/
errors.rs

1/// This error will be returned if an attempt to load Bulwark's configuration file fails.
2#[derive(thiserror::Error, Debug)]
3pub enum ConfigFileError {
4    #[error(transparent)]
5    IO(#[from] std::io::Error),
6    #[error("config file not found: '{0}'")]
7    ConfigNotFound(String),
8    #[error("included config file not found: '{0}'")]
9    IncludedConfigNotFound(String),
10    #[error("included plugin file not found: '{0}'")]
11    PluginNotFound(String),
12    #[error(transparent)]
13    Deserialization(#[from] toml::de::Error),
14    #[error(transparent)]
15    Validation(#[from] validator::ValidationError),
16    #[error(transparent)]
17    Validations(#[from] validator::ValidationErrors),
18    #[error(transparent)]
19    Resolution(#[from] ResolutionError),
20    #[error(transparent)]
21    InvalidRemoteUri(#[from] url::ParseError),
22    #[error("uri must be https: '{0}'")]
23    InsecureRemoteUri(String),
24    #[error("missing parent: '{0}'")]
25    MissingParent(String),
26    #[error("invalid circular include: '{0}'")]
27    CircularInclude(String),
28    #[error("duplicate named plugin or preset: '{0}'")]
29    Duplicate(String),
30    #[error("invalid secret config: {0}")]
31    InvalidSecretConfig(String),
32    #[error("invalid plugin config: {0}")]
33    InvalidPluginConfig(String),
34    #[error("invalid resource config: {0}")]
35    InvalidResourceConfig(String),
36}
37
38/// This error will be returned if an attempt to serialize a config structure fails.
39#[derive(thiserror::Error, Debug)]
40pub enum ConfigSerializationError {
41    #[error(transparent)]
42    Json(#[from] serde_json::Error),
43}
44
45/// This error will be returned if an attempt to convert a secret fails.
46#[derive(thiserror::Error, Debug)]
47pub enum SecretConversionError {
48    #[error("one and only one of path or env_var must be set")]
49    InvalidSecretLocation,
50}
51
52/// This error will be returned if an attempt to convert a plugin fails.
53#[derive(thiserror::Error, Debug)]
54pub enum PluginConversionError {
55    #[error("one and only one of path, uri, or bytes must be set")]
56    InvalidLocation,
57    #[error(transparent)]
58    InvalidRemoteUri(#[from] url::ParseError),
59    #[error(transparent)]
60    InvalidHexEncoding(#[from] hex::FromHexError),
61}
62
63/// This error will be returned if attempting to resolve references fails.
64#[derive(thiserror::Error, Debug)]
65pub enum ResolutionError {
66    #[error("missing named plugin or preset: '{0}'")]
67    Missing(String),
68    #[error("invalid circular preset reference: '{0}'")]
69    CircularPreset(String),
70}