Skip to main content

eggress_config/
error.rs

1#[derive(Debug, thiserror::Error)]
2pub enum ConfigError {
3    #[error("failed to read config file: {0}")]
4    Io(String),
5    #[error("failed to parse TOML: {0}")]
6    Parse(#[from] toml::de::Error),
7    #[error("configuration error at {path}: {message}")]
8    Validation { path: String, message: String },
9    #[error("unsupported config version: {0}")]
10    UnsupportedVersion(u32),
11}
12
13impl ConfigError {
14    pub fn validation(path: &str, message: &str) -> Self {
15        ConfigError::Validation {
16            path: path.to_string(),
17            message: message.to_string(),
18        }
19    }
20}
21
22/// A non-fatal security warning emitted during config validation.
23///
24/// Warnings indicate potentially dangerous configurations that should be
25/// reviewed by the operator but do not prevent the config from loading.
26#[derive(Debug, Clone, PartialEq, Eq)]
27pub struct ConfigWarning {
28    pub path: String,
29    pub message: String,
30}
31
32impl std::fmt::Display for ConfigWarning {
33    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
34        write!(f, "warning at {}: {}", self.path, self.message)
35    }
36}