lll 0.1.1

Simple terminal file manager
Documentation
use std::{fmt, result};

use failure;
use failure::{Backtrace, Context, Fail};

pub type Result<T> = result::Result<T, Error>;

#[derive(Debug)]
pub struct Error {
    inner: Context<ErrorKind>,
}

impl Fail for Error {
    fn cause(&self) -> Option<&dyn Fail> {
        self.inner.cause()
    }

    fn backtrace(&self) -> Option<&Backtrace> {
        self.inner.backtrace()
    }
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        fmt::Display::fmt(&self.inner, f)
    }
}

/// Kinds of error which need to be handled
#[derive(Debug, Fail)]
pub enum ErrorKind {
    #[fail(display = "Directory not found: {}", dirname)]
    DirNotFound { dirname: String },
}

impl From<ErrorKind> for Error {
    fn from(kind: ErrorKind) -> Error {
        Error {
            inner: Context::new(kind),
        }
    }
}

impl From<Context<ErrorKind>> for Error {
    fn from(kind: Context<ErrorKind>) -> Error {
        Error { inner: kind }
    }
}