use thiserror::Error;
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum Error {
#[cfg(feature = "config")]
#[error("failed to parse config file {path}: {source}")]
ConfigParse {
path: String,
source: Box<ConfigParseError>,
},
#[cfg(feature = "config")]
#[error("failed to deserialize config: {0}")]
ConfigDeserialize(serde_json::Error),
#[cfg(feature = "config")]
#[error("config nesting exceeds maximum merge depth")]
ConfigMergeDepth,
#[cfg(feature = "config")]
#[error("no configuration file found")]
ConfigNotFound,
#[cfg(feature = "logging")]
#[error("no writable log directory found")]
LogDirNotWritable,
#[cfg(feature = "otel")]
#[error("failed to initialize OpenTelemetry: {0}")]
OtelInit(opentelemetry_otlp::ExporterBuildError),
#[cfg(feature = "logging")]
#[error("failed to initialize tracing subscriber: {0}")]
TracingInit(tracing_subscriber::util::TryInitError),
#[cfg(feature = "shutdown")]
#[error("failed to register shutdown handler: {0}")]
ShutdownInit(std::io::Error),
#[cfg(feature = "shutdown")]
#[error("no active Tokio runtime: {0}")]
NoRuntime(tokio::runtime::TryCurrentError),
#[cfg(feature = "lockfile")]
#[error("failed to acquire lock: {0}")]
Lock(std::io::Error),
#[cfg(feature = "http")]
#[error("HTTP error: {0}")]
Http(#[from] HttpError),
#[cfg(feature = "cache")]
#[error("cache error: {0}")]
Cache(#[from] CacheError),
#[cfg(feature = "dispatch")]
#[error("dispatch error: {0}")]
Dispatch(std::io::Error),
#[cfg(feature = "diagnostics")]
#[error("diagnostic error: {0}")]
Diagnostic(std::io::Error),
#[error(transparent)]
Io(#[from] std::io::Error),
}
pub type Result<T> = std::result::Result<T, Error>;
#[cfg(feature = "http")]
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum HttpError {
#[error("TLS: {0}")]
Tls(#[from] rustls::Error),
#[error("invalid URL: {0}")]
InvalidUrl(#[from] hyper::http::uri::InvalidUri),
#[error("request build: {0}")]
RequestBuild(#[from] hyper::http::Error),
#[error("request: {0}")]
Request(#[from] hyper_util::client::legacy::Error),
#[error("response body: {0}")]
Body(#[from] hyper::Error),
#[error("{0}")]
Io(#[from] std::io::Error),
#[error("JSON: {0}")]
Json(#[from] serde_json::Error),
}
#[cfg(feature = "cache")]
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum CacheError {
#[error("{0}")]
Io(#[from] std::io::Error),
#[error("JSON: {0}")]
Json(#[from] serde_json::Error),
#[error("decode: {0}")]
Decode(#[from] base64::DecodeError),
}
#[cfg(feature = "config")]
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum ConfigParseError {
#[error("{0}")]
Toml(#[from] toml::de::Error),
#[error("{0}")]
Yaml(#[from] serde_saphyr::Error),
#[error("{0}")]
Json(#[from] serde_json::Error),
#[error("{0}")]
Io(#[from] std::io::Error),
}