1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::error::Error;
use std::fmt;
use slack_hook;

#[derive(Debug)]
pub enum NotifierError {
    Error(slack_hook::Error)
}

impl From<slack_hook::Error> for NotifierError {
    fn from(error: slack_hook::Error) -> Self {
        NotifierError::Error(error)
    }
}

impl Error for NotifierError {
    fn description(&self) -> &str {
        match *self {
            NotifierError::Error(ref err) => err.description()
        }
    }

    fn cause(&self) -> Option<&Error> {
        Some(match *self {
            NotifierError::Error(ref err) => err as &Error
        })
    }
}

impl fmt::Display for NotifierError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            NotifierError::Error(ref err) => fmt::Display::fmt(err, f),
        }
    }
}