#[non_exhaustive]pub enum SettingsError {
Parse {
key: String,
value_kind: &'static str,
},
OutOfRange {
key: String,
message: &'static str,
},
}Expand description
Why a *Settings::from_env call failed. OutboxSettings::from_env (reliar-outbox) was the
first caller; every provider’s own from_env returns this same type, so a host wiring
several from_env calls handles one error type for the whole family.
use reliar_core::SettingsError;
let err = SettingsError::parse("RELIAR_OUTBOX_BATCH_SIZE", "u32");
assert_eq!(err.key(), "RELIAR_OUTBOX_BATCH_SIZE");
assert!(err.to_string().contains("could not be parsed"));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Parse
A present variable could not be parsed as its declared type. The value is never echoed — it may carry an operator’s typo of something sensitive.
Fields
OutOfRange
A present variable parsed but violated a documented bound.
Implementations§
Source§impl SettingsError
Public constructors, because every provider’s from_env returns this type.
SettingsError is #[non_exhaustive], so a crate other than the one defining a given
Settings type — e.g. reliar-store-postgres — cannot build a variant with struct-literal
syntax; without these a provider is forced into a parallel, unrelated error type, and a host
wiring two from_env calls ends up handling two different errors for the same class of
failure (ADR 0019).
impl SettingsError
Public constructors, because every provider’s from_env returns this type.
SettingsError is #[non_exhaustive], so a crate other than the one defining a given
Settings type — e.g. reliar-store-postgres — cannot build a variant with struct-literal
syntax; without these a provider is forced into a parallel, unrelated error type, and a host
wiring two from_env calls ends up handling two different errors for the same class of
failure (ADR 0019).
Sourcepub fn parse(key: impl Into<String>, value_kind: &'static str) -> Self
pub fn parse(key: impl Into<String>, value_kind: &'static str) -> Self
The variable was present but did not parse. value_kind names the expected shape
("u32", "milliseconds"); the offending value is never carried.
use reliar_core::SettingsError;
let err = SettingsError::parse("RELIAR_OUTBOX_BATCH_SIZE", "u32");
assert_eq!(err.key(), "RELIAR_OUTBOX_BATCH_SIZE");Sourcepub fn out_of_range(key: impl Into<String>, message: &'static str) -> Self
pub fn out_of_range(key: impl Into<String>, message: &'static str) -> Self
The variable parsed but is outside the range the setting accepts.
use reliar_core::SettingsError;
let err = SettingsError::out_of_range("RELIAR_OUTBOX_LEASE_SECS", "must be at least 1");
assert!(err.to_string().contains("out of range"));Trait Implementations§
Source§impl Clone for SettingsError
impl Clone for SettingsError
Source§fn clone(&self) -> SettingsError
fn clone(&self) -> SettingsError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SettingsError
impl Debug for SettingsError
Source§impl Display for SettingsError
impl Display for SettingsError
Source§impl Error for SettingsError
impl Error for SettingsError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()