use std::fmt::Display;
use std::fmt::Debug;
use failure::Fail;
#[derive(Debug)]
pub enum Error {
Io(::std::io::Error),
Other(::failure::Error),
}
impl Display for Error {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
Error::Io(e) => write!(f, "{}", e),
Error::Other(e) => write!(f, "{}", e),
}
}
}
impl Fail for Error {
}
impl From<::std::io::Error> for Error {
fn from(ioe: ::std::io::Error) -> Self {
Error::Io(ioe)
}
}
impl From<::failure::Error> for Error {
fn from(fe: ::failure::Error) -> Self {
Error::Other(fe)
}
}
impl<D> From<::failure::Context<D>> for Error
where D: Debug + Display + Send + Sync
{
fn from(ctx: ::failure::Context<D>) -> Self {
Error::Other(ctx.into())
}
}
pub type Result<T> = ::std::result::Result<T, Error>;