ConfigError occurs when the application fails to initialize its environment, read configuration files, or validate settings.

Definition

#[derive(Debug, Error)]
pub enum ConfigError {
    #[error("File not found: {path}")]
    FileNotFound {
        path: PathBuf,
        source: std::io::Error,
    },

    #[error("Parse error: {0}")]
    Parse(String),

    #[error("Missing environment variable: {0}")]
    MissingEnv(String),

    #[error("Invalid value for {key}: {reason}")]
    InvalidValue {
        key: String,
        reason: String,
    },
}

Common Scenarios

  • MissingEnv: The user forgot to set ANTHROPIC_API_KEY.
  • Parse: The provider_config.yaml has invalid YAML syntax.
  • FileNotFound: The specified configuration directory does not exist.

These errors usually cause the application to panic or exit with a non-zero status code immediately after startup.