From 8007ae6abafb95a9c3da6792590ff0cd19d9282c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Thu, 29 Apr 2021 11:40:10 +0200 Subject: update std::error::Error impl for notmuch::Error --- notmuch/src/error.rs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'notmuch/src') 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"), } } } -- cgit v1.2.1