PR: #29 (feat/04-toml-config-loader)
File: crates/charon-core/src/config.rs, lines 79-91
Config::load returns anyhow::Result<Self>. Same rationale as issue #70 for trait: CLI + scanner + tests need to match on error variant (FileNotFound, UnsetEnvVar, ParseError, ValidationError) to decide exit code, retry, or user-friendly message.
Also pair with a Config::from_str(s: &str) -> Result<Self> constructor — current API takes path only, so unit tests must write a tempfile.
Fix:
#[derive(Debug, thiserror::Error)]
pub enum ConfigError {
#[error("config file not found: {0}")]
NotFound(PathBuf),
#[error("read error: {0}")]
Io(#[source] std::io::Error),
#[error("env var `{0}` not set")]
UnsetEnvVar(String),
#[error("unterminated ${{ in config")]
UnterminatedInterp,
#[error("TOML parse: {0}")]
Parse(#[from] toml::de::Error),
#[error("validation: {0}")]
Validation(String),
}
impl Config {
pub fn load(path: impl AsRef<Path>) -> Result<Self, ConfigError> { ... }
pub fn from_str(s: &str) -> Result<Self, ConfigError> { ... }
}
PR: #29 (feat/04-toml-config-loader)
File: crates/charon-core/src/config.rs, lines 79-91
Config::loadreturnsanyhow::Result<Self>. Same rationale as issue #70 for trait: CLI + scanner + tests need to match on error variant (FileNotFound, UnsetEnvVar, ParseError, ValidationError) to decide exit code, retry, or user-friendly message.Also pair with a
Config::from_str(s: &str) -> Result<Self>constructor — current API takes path only, so unit tests must write a tempfile.Fix: