Skip to main content

crabka_connect/config/
error.rs

1use std::error::Error;
2
3/// Result alias for connector configuration work.
4pub type ConfigResult<T> = Result<T, ConfigError>;
5
6/// Errors raised while validating or resolving connector configuration.
7#[derive(Debug, thiserror::Error)]
8pub enum ConfigError {
9    /// The raw config contains a key not declared by `ConfigDef`.
10    #[error("unknown config key `{key}`")]
11    UnknownKey { key: String },
12
13    /// A required key is absent and has no default.
14    #[error("missing required config key `{key}`")]
15    MissingRequired { key: String },
16
17    /// A value did not match the field's declared type.
18    #[error("config key `{key}` expected {expected}")]
19    WrongType { key: String, expected: &'static str },
20
21    /// A default value declared by the config definition is invalid.
22    #[error("invalid default for config key `{key}`: {reason}")]
23    InvalidDefault { key: String, reason: String },
24
25    /// A secret field did not contain a supported reference object.
26    #[error("invalid secret reference for config key `{key}`: {reason}")]
27    InvalidSecretRef { key: String, reason: String },
28
29    /// A resolver failed to fetch the referenced secret.
30    #[error("failed to resolve secret for config key `{key}`: {source}")]
31    SecretResolution {
32        key: String,
33        #[source]
34        source: Box<dyn Error + Send + Sync>,
35    },
36}