diff options
Diffstat (limited to 'notmuch/src')
| -rw-r--r-- | notmuch/src/error.rs | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/notmuch/src/error.rs b/notmuch/src/error.rs index 64d0716..701bc78 100644 --- a/notmuch/src/error.rs +++ b/notmuch/src/error.rs @@ -1,5 +1,5 @@ use std; -use std::{error, fmt, io, result}; +use std::{fmt, io, result}; use ffi; @@ -12,26 +12,14 @@ pub enum Error { UnspecifiedError, } +impl std::error::Error for Error {} + impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", error::Error::description(self)) - } -} - -impl std::error::Error for Error { - fn description(&self) -> &str { match self { - Error::IoError(e) => error::Error::description(e), - Error::NotmuchError(e) => e.description(), - Error::UnspecifiedError => "Generic notmuch error", - } - } - - fn cause(&self) -> Option<&dyn error::Error> { - match *self { - Error::IoError(ref e) => Some(e), - Error::NotmuchError(ref e) => Some(e), - Error::UnspecifiedError => None, + Error::IoError(e) => write!(f, "IO error: {}", e), + Error::NotmuchError(e) => write!(f, "notmuch error: {}", e), + Error::UnspecifiedError => write!(f, "unspecified error"), } } } |
