use std::path::PathBuf;
use miette::Diagnostic;
use thiserror::Error;
#[derive(Debug, Error, Diagnostic)]
#[non_exhaustive]
pub enum ConfigError {
#[error("configuration error: {0}")]
#[diagnostic(
code(rtb::config::parse),
help("check your config file and environment variables against the schema")
)]
Parse(String),
#[error("could not read config file {path}: {source}")]
#[diagnostic(code(rtb::config::io))]
Io {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("config watcher error: {0}")]
#[diagnostic(code(rtb::config::watch))]
Watch(String),
#[error("config write error: {0}")]
#[diagnostic(code(rtb::config::write))]
Write(String),
#[error("config schema violation: {0}")]
#[diagnostic(code(rtb::config::schema))]
Schema(String),
}
impl From<figment::Error> for ConfigError {
fn from(value: figment::Error) -> Self {
Self::Parse(value.to_string())
}
}