Skip to main content

aa_storage/
error.rs

1//! [`ConfigError`] — failures raised while resolving storage drivers from config.
2
3/// Error returned when a `[storage]` configuration cannot be resolved against
4/// the driver [`Registry`](crate::Registry).
5#[derive(Debug, thiserror::Error)]
6#[non_exhaustive]
7pub enum ConfigError {
8    /// A driver name in `[storage]` is not registered for its kind.
9    ///
10    /// `available` lists every driver name registered for `kind`, so the
11    /// operator can see the valid choices in the error message.
12    #[error("unknown {kind} driver {name:?}; available drivers: [{}]", available.join(", "))]
13    UnknownDriver {
14        /// The storage-kind key that named the driver (e.g. `"policy_store"`).
15        kind: &'static str,
16        /// The unrecognized driver name from the config.
17        name: String,
18        /// Driver names registered for this kind, in sorted order.
19        available: Vec<String>,
20    },
21
22    /// A driver was named but its `[storage.<name>]` subsection is missing.
23    #[error("driver {name:?} (selected for {kind}) has no [storage.{name}] subsection")]
24    MissingDriverSection {
25        /// The storage-kind key that named the driver.
26        kind: &'static str,
27        /// The driver name whose subsection is absent.
28        name: String,
29    },
30
31    /// The driver's factory failed to build the backend from its subsection.
32    #[error("failed to build {kind} driver {name:?}: {source}")]
33    Build {
34        /// The storage-kind key that named the driver.
35        kind: &'static str,
36        /// The driver name being built.
37        name: String,
38        /// The underlying backend error.
39        #[source]
40        source: crate::StorageError,
41    },
42}