use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("reading config file {}", path.display())]
ReadConfig {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("parsing config{}", match path { Some(p) => format!(" file {}", p.display()), None => String::new() })]
Toml {
path: Option<PathBuf>,
#[source]
source: toml::de::Error,
},
#[error("{key} {reason}")]
InvalidConfig { key: &'static str, reason: String },
#[error("route prefix {prefix:?} must start with '/'")]
InvalidPrefix { prefix: String },
#[error("route prefix {prefix:?} is not normalised; write it as {normal:?}")]
NonCanonicalPrefix { prefix: String, normal: String },
#[error("duplicate route prefix {prefix:?}")]
DuplicatePrefix { prefix: String },
#[error("route {route:?}: {reason}")]
InvalidUpstream {
route: String,
upstream: String,
reason: String,
#[source]
source: Option<http::uri::InvalidUri>,
},
#[error("route {route:?}: cooldown_secs {reason}")]
InvalidCooldown { route: String, reason: String },
#[error(
"route {route:?}: upstream {upstream} is shared with another route but has a \
different cooldown ({cooldown_secs}s vs {other_secs}s); routes to one upstream share one breaker"
)]
ConflictingCooldown {
route: String,
upstream: String,
cooldown_secs: u64,
other_secs: u64,
},
#[error("route {route:?}: health_path {path:?} must start with '/' and contain no '?' or '#'")]
InvalidHealthPath { route: String, path: String },
#[error(
"route {route:?}: upstream {upstream} is shared with another route but has a \
different {setting} ({value} vs {other}); routes to one upstream share one health check"
)]
ConflictingHealth {
route: String,
upstream: String,
setting: &'static str,
value: String,
other: String,
},
#[error("trusted_proxies entry {entry:?}: {reason}")]
InvalidCidr { entry: String, reason: String },
#[error("{reason}{}", upstream.as_ref().map(|u| format!(" (upstream {u})")).unwrap_or_default())]
InvalidBreakerConfig {
reason: String,
upstream: Option<String>,
},
}
const _: fn() = || {
fn assert<T: std::error::Error + Send + Sync + 'static>() {}
assert::<Error>();
};