1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
//! The error module contains a generic error that is used by the rest of the crate.
//!
#[derive(Debug)]
pub struct Error {
details: String,
}
impl Error {
pub fn new(msg: &str) -> Error {
Error {
details: msg.to_string(),
}
}
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Error {
Error::new(&e.to_string())
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.details)
}
}
impl std::error::Error for Error {}