octoon/error/
mod.rs

1use std::error;
2use std::fmt;
3use std::io;
4
5pub enum Error {
6    IoError(io::Error),
7}
8
9impl fmt::Display for Error {
10    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
11        match *self {
12            Error::IoError(ref err) => write!(f, "IoError {{ {} }}", err),
13        }
14    }
15}
16
17impl fmt::Debug for Error {
18    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
19        fmt::Display::fmt(self, f)
20    }
21}
22
23impl std::error::Error for Error {
24    fn description(&self) -> &str {
25        match *self {
26            Error::IoError(_) => "I/O Error",
27        }
28    }
29
30    fn cause(&self) -> Option<&error::Error> {
31        match *self {
32            Error::IoError(ref err) => Some(err)
33        }
34    }
35}
36
37impl From<io::Error> for Error {
38    fn from(err: io::Error) -> Error {
39        Error::IoError(err)
40    }
41}