use thiserror::Error; /// Represents errors that can occur during application configuration. /// /// These errors typically happen during application startup when loading /// and validating configuration from environment variables and files. #[derive(Debug, Error)] pub enum ConfigError { /// Error when a required environment variable is not set. /// /// This error occurs when the application starts up and a required /// environment variable is missing from the execution environment. #[error("error-smokesignal-config-1 {0} must be set")] EnvVarRequired(String), /// Error when no valid signing keys are found. /// /// This error occurs when the OAuth client credentials key is empty /// or cannot be identified as a valid key. #[error("error-smokesignal-config-4 OAuth client credentials key must be a valid key")] EmptySigningKeys, /// Error when the PORT environment variable cannot be parsed. /// /// This error occurs when the PORT environment variable contains a value /// that cannot be parsed as a valid u16 integer. #[error("error-smokesignal-config-7 Parsing PORT into u16 failed: {0:?}")] PortParsingFailed(std::num::ParseIntError), /// Error when the HTTP_COOKIE_KEY cannot be decoded. /// /// This error occurs when the HTTP_COOKIE_KEY environment variable /// contains a value that is not valid base64-encoded data. #[error("error-smokesignal-config-8 Unable to base64 decode HTTP_COOKIE_KEY: {0:?}")] CookieKeyDecodeFailed(base64::DecodeSliceError), /// Error when the decoded HTTP_COOKIE_KEY cannot be processed. /// /// This error occurs when the decoded HTTP_COOKIE_KEY has an invalid /// format or length that prevents it from being used. #[error("error-smokesignal-config-9 Unable to process decoded HTTP_COOKIE_KEY")] CookieKeyProcessFailed, /// Error when version information is not available. /// /// This error occurs when neither GIT_HASH nor CARGO_PKG_VERSION /// environment variables are set, preventing version identification. #[error("error-smokesignal-config-10 One of GIT_HASH or CARGO_PKG_VERSION must be set")] VersionNotSet, /// Error when a DNS nameserver IP cannot be parsed. /// /// This error occurs when the DNS_NAMESERVERS environment variable contains /// an IP address that cannot be parsed as a valid IpAddr. #[error("error-smokesignal-config-12 Unable to parse nameserver IP '{0}': {1}")] NameserverParsingFailed(String, std::net::AddrParseError), /// Error when the EMAIL_SECRET_KEY cannot be decoded. /// /// This error occurs when the EMAIL_SECRET_KEY environment variable /// contains a value that is not valid hex-encoded data. #[error("error-smokesignal-config-21 Unable to hex decode EMAIL_SECRET_KEY: {0:?}")] EmailSecretKeyDecodeFailed(hex::FromHexError), /// Error when the EMAIL_SECRET_KEY is too short. /// /// This error occurs when the decoded EMAIL_SECRET_KEY is less than /// 32 bytes (256 bits), which is the minimum required for security. #[error( "error-smokesignal-config-22 EMAIL_SECRET_KEY must be at least 32 bytes, got {0} bytes" )] EmailSecretKeyTooShort(usize), }