You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
735 B
30 lines
735 B
use std::error::Error;
|
|
use std::fmt;
|
|
|
|
#[derive(Debug)]
|
|
pub struct ConfigError {
|
|
description: String,
|
|
original_error: Option<Box<Error>>,
|
|
}
|
|
|
|
impl ConfigError {
|
|
pub fn new(description: &str, original_error: Option<Box<Error>>) -> ConfigError {
|
|
ConfigError {
|
|
description: String::from(description),
|
|
original_error,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Error for ConfigError {}
|
|
|
|
impl fmt::Display for ConfigError {
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
match &self.original_error {
|
|
Some(original_error) => {
|
|
write!(f, "{}: \"{}\"", self.description, original_error)
|
|
}
|
|
None => write!(f, "{}", self.description)
|
|
}
|
|
}
|
|
}
|