diff --git a/melib/src/backends.rs b/melib/src/backends.rs index e958c11a..57ef9feb 100644 --- a/melib/src/backends.rs +++ b/melib/src/backends.rs @@ -50,7 +50,7 @@ pub use self::imap::ImapType; #[cfg(feature = "imap_backend")] pub use self::nntp::NntpType; use crate::conf::AccountSettings; -use crate::error::{MeliError, Result}; +use crate::error::{ErrorKind, MeliError, Result}; #[cfg(feature = "maildir_backend")] use self::maildir::MaildirType; @@ -360,14 +360,14 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync { &mut self, _path: String, ) -> ResultFuture<(MailboxHash, HashMap)> { - Err(MeliError::new("Unimplemented.")) + Err(MeliError::new("Unimplemented.").set_kind(ErrorKind::NotImplemented)) } fn delete_mailbox( &mut self, _mailbox_hash: MailboxHash, ) -> ResultFuture> { - Err(MeliError::new("Unimplemented.")) + Err(MeliError::new("Unimplemented.").set_kind(ErrorKind::NotImplemented)) } fn set_mailbox_subscription( @@ -375,7 +375,7 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync { _mailbox_hash: MailboxHash, _val: bool, ) -> ResultFuture<()> { - Err(MeliError::new("Unimplemented.")) + Err(MeliError::new("Unimplemented.").set_kind(ErrorKind::NotImplemented)) } fn rename_mailbox( @@ -383,7 +383,7 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync { _mailbox_hash: MailboxHash, _new_path: String, ) -> ResultFuture { - Err(MeliError::new("Unimplemented.")) + Err(MeliError::new("Unimplemented.").set_kind(ErrorKind::NotImplemented)) } fn set_mailbox_permissions( @@ -391,7 +391,7 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync { _mailbox_hash: MailboxHash, _val: MailboxPermissions, ) -> ResultFuture<()> { - Err(MeliError::new("Unimplemented.")) + Err(MeliError::new("Unimplemented.").set_kind(ErrorKind::NotImplemented)) } fn search( @@ -399,7 +399,7 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync { _query: crate::search::Query, _mailbox_hash: Option, ) -> ResultFuture> { - Err(MeliError::new("Unimplemented.")) + Err(MeliError::new("Unimplemented.").set_kind(ErrorKind::NotImplemented)) } fn submit( @@ -408,7 +408,7 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync { _mailbox_hash: Option, _flags: Option, ) -> ResultFuture<()> { - Err(MeliError::new("Not supported in this backend.")) + Err(MeliError::new("Not supported in this backend.").set_kind(ErrorKind::NotSupported)) } } diff --git a/melib/src/backends/nntp.rs b/melib/src/backends/nntp.rs index 9a0cfc65..842b6547 100644 --- a/melib/src/backends/nntp.rs +++ b/melib/src/backends/nntp.rs @@ -352,7 +352,7 @@ impl MailBackend for NntpType { } fn watch(&self) -> ResultFuture<()> { - Err(MeliError::new("Unimplemented.")) + Err(MeliError::new("Unimplemented.").set_kind(ErrorKind::NotImplemented)) } fn operation(&self, env_hash: EnvelopeHash) -> Result> { diff --git a/melib/src/error.rs b/melib/src/error.rs index 045ee3fd..aa83de73 100644 --- a/melib/src/error.rs +++ b/melib/src/error.rs @@ -42,6 +42,9 @@ pub enum ErrorKind { Bug, Network, Timeout, + OSError, + NotImplemented, + NotSupported, } impl fmt::Display for ErrorKind { @@ -56,6 +59,9 @@ impl fmt::Display for ErrorKind { ErrorKind::Bug => "Bug, please report this!", ErrorKind::Network => "Network", ErrorKind::Timeout => "Timeout", + ErrorKind::OSError => "OS Error", + ErrorKind::NotImplemented => "Not implemented", + ErrorKind::NotSupported => "Not supported", } ) } @@ -208,6 +214,7 @@ impl From for MeliError { MeliError::new(kind.to_string()) .set_summary(format!("{:?}", kind.kind())) .set_source(Some(Arc::new(kind))) + .set_kind(ErrorKind::OSError) } } diff --git a/src/conf/accounts.rs b/src/conf/accounts.rs index 2ceab672..42e9d9f0 100644 --- a/src/conf/accounts.rs +++ b/src/conf/accounts.rs @@ -28,7 +28,7 @@ use crate::jobs::{JobExecutor, JobId, JoinHandle}; use indexmap::IndexMap; use melib::backends::*; use melib::email::*; -use melib::error::{MeliError, Result}; +use melib::error::{ErrorKind, MeliError, Result}; use melib::text_processing::GlobMatch; use melib::thread::{SortField, SortOrder, Threads}; use melib::AddressBook; @@ -1078,6 +1078,9 @@ impl Account { self.active_jobs .insert(handle.job_id, JobRequest::Watch { handle }); } + Err(e) + if e.kind == ErrorKind::NotSupported || e.kind == ErrorKind::NotImplemented => { + } Err(e) => { self.sender .send(ThreadEvent::UIEvent(UIEvent::StatusEvent(