use std::{fmt, path::PathBuf};
#[derive(Clone, Debug)]
pub enum Error {
CannotLoadFromFS(PathBuf, Reason),
CannotLoadFromLogical(String, Reason),
IOError(String),
}
pub type Reason = String;
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
Error::CannotLoadFromFS(ref path, ref reason) => {
write!(
f,
"cannot load {} from file system: {}",
path.display(),
reason
)
}
Error::CannotLoadFromLogical(ref s, ref reason) => {
write!(f, "cannot load <{}>: {}", s, reason)
}
Error::IOError(ref e) => write!(f, "{}", e),
}
}
}