use thiserror::Error; #[derive(Debug, Error)] pub enum ConfigError { #[error("failed to load .env file: {0}")] DotEnv(#[from] dotenvy::Error), #[error("config parse/merge error: {0}")] Figment(Box), #[error("config I/O error: {0}")] Io(#[from] std::io::Error), #[error("config validation failed: {0}")] Validation(String), } impl From for ConfigError { fn from(error: figment::Error) -> Self { // Boxed because a figment error carries ~200 bytes of provenance; an // inline variant would make every `Result<_, ConfigError>` in the // workspace pay for it on the success path too. Self::Figment(Box::new(error)) } }