use std::{fmt, io};
#[derive(Debug)]
pub enum Error {
BadFormat(String),
IO(io::Error)
}
impl Error {
#[allow(clippy::needless_pass_by_value)]
pub fn bad_format(s: impl ToString) -> Self {
Self::BadFormat(s.to_string())
}
}
impl std::error::Error for Error {}
impl From<io::Error> for Error {
fn from(err: io::Error) -> Self {
Self::IO(err)
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::BadFormat(s) => write!(f, "Bad format error; {s}"),
Self::IO(e) => write!(f, "I/O error; {e}")
}
}
}