use std::error::Error;
use std::fmt::Display;
#[derive(Debug, PartialEq, Eq)]
pub struct ConfigError {
message: &'static str,
file: String,
line: u64,
}
impl ConfigError {
pub fn new(message: &'static str, file: &str, line: u64) -> Self {
Self {
message,
file: file.to_string(),
line,
}
}
}
impl Display for ConfigError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"Configuration error at {} line {}: {}",
self.file, self.line, self.message
)
}
}
impl Error for ConfigError {}