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")]
|
#[cfg(feature = "imap_backend")]
|
||||||
pub use self::nntp::NntpType;
|
pub use self::nntp::NntpType;
|
||||||
use crate::conf::AccountSettings;
|
use crate::conf::AccountSettings;
|
||||||
use crate::error::{MeliError, Result};
|
use crate::error::{ErrorKind, MeliError, Result};
|
||||||
|
|
||||||
#[cfg(feature = "maildir_backend")]
|
#[cfg(feature = "maildir_backend")]
|
||||||
use self::maildir::MaildirType;
|
use self::maildir::MaildirType;
|
||||||
@ -360,14 +360,14 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
|
|||||||
&mut self,
|
&mut self,
|
||||||
_path: String,
|
_path: String,
|
||||||
) -> ResultFuture<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
|
) -> ResultFuture<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
|
||||||
Err(MeliError::new("Unimplemented."))
|
Err(MeliError::new("Unimplemented.").set_kind(ErrorKind::NotImplemented))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete_mailbox(
|
fn delete_mailbox(
|
||||||
&mut self,
|
&mut self,
|
||||||
_mailbox_hash: MailboxHash,
|
_mailbox_hash: MailboxHash,
|
||||||
) -> ResultFuture<HashMap<MailboxHash, Mailbox>> {
|
) -> ResultFuture<HashMap<MailboxHash, Mailbox>> {
|
||||||
Err(MeliError::new("Unimplemented."))
|
Err(MeliError::new("Unimplemented.").set_kind(ErrorKind::NotImplemented))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_mailbox_subscription(
|
fn set_mailbox_subscription(
|
||||||
@ -375,7 +375,7 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
|
|||||||
_mailbox_hash: MailboxHash,
|
_mailbox_hash: MailboxHash,
|
||||||
_val: bool,
|
_val: bool,
|
||||||
) -> ResultFuture<()> {
|
) -> ResultFuture<()> {
|
||||||
Err(MeliError::new("Unimplemented."))
|
Err(MeliError::new("Unimplemented.").set_kind(ErrorKind::NotImplemented))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rename_mailbox(
|
fn rename_mailbox(
|
||||||
@ -383,7 +383,7 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
|
|||||||
_mailbox_hash: MailboxHash,
|
_mailbox_hash: MailboxHash,
|
||||||
_new_path: String,
|
_new_path: String,
|
||||||
) -> ResultFuture<Mailbox> {
|
) -> ResultFuture<Mailbox> {
|
||||||
Err(MeliError::new("Unimplemented."))
|
Err(MeliError::new("Unimplemented.").set_kind(ErrorKind::NotImplemented))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_mailbox_permissions(
|
fn set_mailbox_permissions(
|
||||||
@ -391,7 +391,7 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
|
|||||||
_mailbox_hash: MailboxHash,
|
_mailbox_hash: MailboxHash,
|
||||||
_val: MailboxPermissions,
|
_val: MailboxPermissions,
|
||||||
) -> ResultFuture<()> {
|
) -> ResultFuture<()> {
|
||||||
Err(MeliError::new("Unimplemented."))
|
Err(MeliError::new("Unimplemented.").set_kind(ErrorKind::NotImplemented))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn search(
|
fn search(
|
||||||
@ -399,7 +399,7 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
|
|||||||
_query: crate::search::Query,
|
_query: crate::search::Query,
|
||||||
_mailbox_hash: Option<MailboxHash>,
|
_mailbox_hash: Option<MailboxHash>,
|
||||||
) -> ResultFuture<SmallVec<[EnvelopeHash; 512]>> {
|
) -> ResultFuture<SmallVec<[EnvelopeHash; 512]>> {
|
||||||
Err(MeliError::new("Unimplemented."))
|
Err(MeliError::new("Unimplemented.").set_kind(ErrorKind::NotImplemented))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn submit(
|
fn submit(
|
||||||
@ -408,7 +408,7 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
|
|||||||
_mailbox_hash: Option<MailboxHash>,
|
_mailbox_hash: Option<MailboxHash>,
|
||||||
_flags: Option<Flag>,
|
_flags: Option<Flag>,
|
||||||
) -> ResultFuture<()> {
|
) -> 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<()> {
|
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>> {
|
fn operation(&self, env_hash: EnvelopeHash) -> Result<Box<dyn BackendOp>> {
|
||||||
|
@ -42,6 +42,9 @@ pub enum ErrorKind {
|
|||||||
Bug,
|
Bug,
|
||||||
Network,
|
Network,
|
||||||
Timeout,
|
Timeout,
|
||||||
|
OSError,
|
||||||
|
NotImplemented,
|
||||||
|
NotSupported,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for ErrorKind {
|
impl fmt::Display for ErrorKind {
|
||||||
@ -56,6 +59,9 @@ impl fmt::Display for ErrorKind {
|
|||||||
ErrorKind::Bug => "Bug, please report this!",
|
ErrorKind::Bug => "Bug, please report this!",
|
||||||
ErrorKind::Network => "Network",
|
ErrorKind::Network => "Network",
|
||||||
ErrorKind::Timeout => "Timeout",
|
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())
|
MeliError::new(kind.to_string())
|
||||||
.set_summary(format!("{:?}", kind.kind()))
|
.set_summary(format!("{:?}", kind.kind()))
|
||||||
.set_source(Some(Arc::new(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 indexmap::IndexMap;
|
||||||
use melib::backends::*;
|
use melib::backends::*;
|
||||||
use melib::email::*;
|
use melib::email::*;
|
||||||
use melib::error::{MeliError, Result};
|
use melib::error::{ErrorKind, MeliError, Result};
|
||||||
use melib::text_processing::GlobMatch;
|
use melib::text_processing::GlobMatch;
|
||||||
use melib::thread::{SortField, SortOrder, Threads};
|
use melib::thread::{SortField, SortOrder, Threads};
|
||||||
use melib::AddressBook;
|
use melib::AddressBook;
|
||||||
@ -1078,6 +1078,9 @@ impl Account {
|
|||||||
self.active_jobs
|
self.active_jobs
|
||||||
.insert(handle.job_id, JobRequest::Watch { handle });
|
.insert(handle.job_id, JobRequest::Watch { handle });
|
||||||
}
|
}
|
||||||
|
Err(e)
|
||||||
|
if e.kind == ErrorKind::NotSupported || e.kind == ErrorKind::NotImplemented => {
|
||||||
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
self.sender
|
self.sender
|
||||||
.send(ThreadEvent::UIEvent(UIEvent::StatusEvent(
|
.send(ThreadEvent::UIEvent(UIEvent::StatusEvent(
|
||||||
|
Loading…
Reference in New Issue
Block a user