diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-04-29 11:40:10 +0200 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-04-29 11:40:10 +0200 |
| commit | 8007ae6abafb95a9c3da6792590ff0cd19d9282c (patch) | |
| tree | 16b4b1c9458874fb5d35a0f45a1ca1c8fb02e04e /notmuch | |
| parent | 7336a50caa97c1ff83e77796a3cdd383ea7ed3ba (diff) | |
| download | mail-8007ae6abafb95a9c3da6792590ff0cd19d9282c.tar.gz | |
update std::error::Error impl for notmuch::Error
Diffstat (limited to 'notmuch')
| -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"), } } } |
