mirror of
https://git.meli.delivery/meli/meli
synced 2024-11-10 19:10:57 +00:00
melib/error: Add kinds: NotImplemented, NotSupported, OSError
This commit is contained in:
parent
72a2ba20dc
commit
07e166e1fb
@ -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<MailboxHash, Mailbox>)> {
|
||||
Err(MeliError::new("Unimplemented."))
|
||||
Err(MeliError::new("Unimplemented.").set_kind(ErrorKind::NotImplemented))
|
||||
}
|
||||
|
||||
fn delete_mailbox(
|
||||
&mut self,
|
||||
_mailbox_hash: MailboxHash,
|
||||
) -> ResultFuture<HashMap<MailboxHash, Mailbox>> {
|
||||
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<Mailbox> {
|
||||
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<MailboxHash>,
|
||||
) -> ResultFuture<SmallVec<[EnvelopeHash; 512]>> {
|
||||
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<MailboxHash>,
|
||||
_flags: Option<Flag>,
|
||||
) -> ResultFuture<()> {
|
||||
Err(MeliError::new("Not supported in this backend."))
|
||||
Err(MeliError::new("Not supported in this backend.").set_kind(ErrorKind::NotSupported))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<Box<dyn BackendOp>> {
|
||||
|
@ -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<io::Error> for MeliError {
|
||||
MeliError::new(kind.to_string())
|
||||
.set_summary(format!("{:?}", kind.kind()))
|
||||
.set_source(Some(Arc::new(kind)))
|
||||
.set_kind(ErrorKind::OSError)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user