#[derive(Debug)]
pub enum Error {
IoError(std::io::Error),
FormatError(Box<dyn std::error::Error + Send + Sync + 'static>),
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Error::IoError(e) => e.source(),
Error::FormatError(e) => Some(e.as_ref()),
}
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self {
Error::IoError(ref err) => err.fmt(f),
Error::FormatError(ref inner) => write!(f, "format error: {}", inner),
}
}
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Self::IoError(e)
}
}