diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2022-12-08 22:20:05 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2022-12-08 22:20:05 +0200 |
commit | 5634f9555315deb2d39ed8fce577a35f4d535ac1 (patch) | |
tree | 8f4937abcd505603d8817b40bcfde5cf50362900 /src | |
parent | 259aeb00877557ee85b5cc555d50e605b85b3109 (diff) | |
download | meli-5634f9555315deb2d39ed8fce577a35f4d535ac1.zip |
Rename MeliError struct to Error
Diffstat (limited to 'src')
-rw-r--r-- | src/command.rs | 4 | ||||
-rw-r--r-- | src/components/mail/compose.rs | 8 | ||||
-rw-r--r-- | src/components/mail/compose/gpg.rs | 6 | ||||
-rw-r--r-- | src/components/mail/view.rs | 12 | ||||
-rw-r--r-- | src/conf.rs | 70 | ||||
-rw-r--r-- | src/conf/accounts.rs | 34 | ||||
-rw-r--r-- | src/conf/listing.rs | 4 | ||||
-rw-r--r-- | src/conf/notifications.rs | 4 | ||||
-rw-r--r-- | src/conf/pager.rs | 4 | ||||
-rw-r--r-- | src/conf/shortcuts.rs | 6 | ||||
-rw-r--r-- | src/conf/tags.rs | 4 | ||||
-rw-r--r-- | src/conf/terminal.rs | 6 | ||||
-rw-r--r-- | src/conf/themes.rs | 8 | ||||
-rw-r--r-- | src/mailcap.rs | 12 | ||||
-rw-r--r-- | src/main.rs | 10 | ||||
-rw-r--r-- | src/plugins.rs | 4 | ||||
-rw-r--r-- | src/plugins/backend.rs | 16 | ||||
-rw-r--r-- | src/plugins/rpc.rs | 18 | ||||
-rw-r--r-- | src/sqlite3.rs | 22 | ||||
-rw-r--r-- | src/state.rs | 2 | ||||
-rw-r--r-- | src/terminal/embed/grid.rs | 4 |
21 files changed, 129 insertions, 129 deletions
diff --git a/src/command.rs b/src/command.rs index 525d69f5..ea376922 100644 --- a/src/command.rs +++ b/src/command.rs @@ -34,7 +34,7 @@ use melib::nom::{ IResult, }; pub use melib::thread::{SortField, SortOrder}; -use melib::MeliError; +use melib::Error; pub mod actions; use actions::MailboxOperation; use std::collections::HashSet; @@ -952,7 +952,7 @@ fn view(input: &[u8]) -> IResult<&[u8], Action> { ))(input) } -pub fn parse_command(input: &[u8]) -> Result<Action, MeliError> { +pub fn parse_command(input: &[u8]) -> Result<Action, Error> { alt(( goto, listing_action, diff --git a/src/components/mail/compose.rs b/src/components/mail/compose.rs index 7cd5f615..b2362964 100644 --- a/src/components/mail/compose.rs +++ b/src/components/mail/compose.rs @@ -1253,7 +1253,7 @@ impl Component for Composer { .chan .try_recv() .map_err(|_: futures::channel::oneshot::Canceled| { - MeliError::new("Job was canceled") + Error::new("Job was canceled") }) { Err(err) | Ok(Some(Err(err))) => { self.mode = ViewMode::Edit; @@ -1540,7 +1540,7 @@ impl Component for Composer { match melib::email::parser::address::rfc2822address_list( self.form.values()["From"].as_str().as_bytes(), ) - .map_err(|_err| -> MeliError { "No valid sender address in `From:`".into() }) + .map_err(|_err| -> Error { "No valid sender address in `From:`".into() }) .and_then(|(_, list)| { list.get(0) .cloned() @@ -1580,7 +1580,7 @@ impl Component for Composer { match melib::email::parser::address::rfc2822address_list( self.form.values()["To"].as_str().as_bytes(), ) - .map_err(|_err| -> MeliError { "No valid recipient addresses in `To:`".into() }) + .map_err(|_err| -> Error { "No valid recipient addresses in `To:`".into() }) .and_then(|(_, list)| { list.get(0) .cloned() @@ -2217,7 +2217,7 @@ pub fn save_draft( account_hash: AccountHash, ) { match context.accounts[&account_hash].save_special(bytes, mailbox_type, flags) { - Err(MeliError { + Err(Error { summary, details, kind, diff --git a/src/components/mail/compose/gpg.rs b/src/components/mail/compose/gpg.rs index eaba98f7..f79b3a1a 100644 --- a/src/components/mail/compose/gpg.rs +++ b/src/components/mail/compose/gpg.rs @@ -33,7 +33,7 @@ pub enum KeySelection { }, Error { id: ComponentId, - err: MeliError, + err: Error, }, Loaded { widget: Box<UIDialog<melib::gpgme::Key>>, @@ -140,7 +140,7 @@ impl Component for KeySelection { } } else if !*local && allow_remote_lookup.is_ask() { *self = KeySelection::Error { - err: MeliError::new(format!( + err: Error::new(format!( "No keys found for {}, perform remote lookup?", pattern )), @@ -148,7 +148,7 @@ impl Component for KeySelection { } } else { *self = KeySelection::Error { - err: MeliError::new(format!( + err: Error::new(format!( "No keys found for {}.", pattern )), diff --git a/src/components/mail/view.rs b/src/components/mail/view.rs index 7ccd352d..84e56228 100644 --- a/src/components/mail/view.rs +++ b/src/components/mail/view.rs @@ -114,7 +114,7 @@ pub enum AttachmentDisplay { SignedFailed { inner: Box<Attachment>, display: Vec<AttachmentDisplay>, - error: MeliError, + error: Error, }, SignedUnverified { inner: Box<Attachment>, @@ -131,7 +131,7 @@ pub enum AttachmentDisplay { }, EncryptedFailed { inner: Box<Attachment>, - error: MeliError, + error: Error, }, EncryptedSuccess { inner: Box<Attachment>, @@ -184,7 +184,7 @@ enum MailViewState { pending_action: Option<PendingReplyAction>, }, Error { - err: MeliError, + err: Error, }, Loaded { bytes: Vec<u8>, @@ -893,7 +893,7 @@ impl MailView { { acc.push(AttachmentDisplay::EncryptedFailed { inner: Box::new(a.clone()), - error: MeliError::new("Cannot decrypt: meli must be compiled with libgpgme support."), + error: Error::new("Cannot decrypt: meli must be compiled with libgpgme support."), }); } #[cfg(feature = "gpgme")] @@ -916,7 +916,7 @@ impl MailView { } else { acc.push(AttachmentDisplay::EncryptedFailed { inner: Box::new(a.clone()), - error: MeliError::new("Undecrypted."), + error: Error::new("Undecrypted."), }); } } @@ -1528,7 +1528,7 @@ impl Component for MailView { .join(&b"\n"[..])) }) .map(|v| String::from_utf8_lossy(&v).into_owned()) - .unwrap_or_else(|err: MeliError| err.to_string()); + .unwrap_or_else(|err: Error| err.to_string()); if !ret.ends_with("\n\n") { ret.push_str("\n\n"); } diff --git a/src/conf.rs b/src/conf.rs index 10a55f97..08d31085 100644 --- a/src/conf.rs +++ b/src/conf.rs @@ -285,7 +285,7 @@ impl From<FileAccount> for AccountConf { pub fn get_config_file() -> Result<PathBuf> { let xdg_dirs = xdg::BaseDirectories::with_prefix("meli").map_err(|err| { - MeliError::new(format!( + Error::new(format!( "Could not detect XDG directories for user: {}", err )) @@ -344,7 +344,7 @@ impl FileSettings { if !config_path.exists() { let path_string = config_path.display().to_string(); if path_string.is_empty() { - return Err(MeliError::new("No configuration found.")); + return Err(Error::new("No configuration found.")); } #[cfg(not(test))] let ask = Ask { @@ -356,13 +356,13 @@ impl FileSettings { #[cfg(not(test))] if ask.run() { create_config_file(&config_path)?; - return Err(MeliError::new( + return Err(Error::new( "Edit the sample configuration and relaunch meli.", )); } #[cfg(test)] return Ok(FileSettings::default()); - return Err(MeliError::new("No configuration file found.")); + return Err(Error::new("No configuration file found.")); } FileSettings::validate(config_path, true, false) @@ -372,7 +372,7 @@ impl FileSettings { let s = pp::pp(&path)?; let map: toml::map::Map<String, toml::value::Value> = toml::from_str(&s).map_err(|err| { - MeliError::new(format!( + Error::new(format!( "{}:\nConfig file is invalid TOML: {}", path.display(), err @@ -401,7 +401,7 @@ This is required so that you don't accidentally start meli and find out later th let mut file = OpenOptions::new().append(true).open(&path)?; file.write_all("[composing]\nsend_mail = 'false'\n".as_bytes()) .map_err(|err| { - MeliError::new(format!( + Error::new(format!( "Could not append to {}: {}", path.display(), err @@ -410,14 +410,14 @@ This is required so that you don't accidentally start meli and find out later th return FileSettings::validate(path, interactive, clear_extras); } } - return Err(MeliError::new(format!( + return Err(Error::new(format!( "{}\n\nEdit the {} and relaunch meli.", if interactive { "" } else { err_msg }, path.display() ))); } let mut s: FileSettings = toml::from_str(&s).map_err(|err| { - MeliError::new(format!( + Error::new(format!( "{}:\nConfig file contains errors: {}", path.display(), err @@ -450,7 +450,7 @@ This is required so that you don't accidentally start meli and find out later th "dark" | "light" => {} t if s.terminal.themes.other_themes.contains_key(t) => {} t => { - return Err(MeliError::new(format!("Theme `{}` was not found.", t))); + return Err(Error::new(format!("Theme `{}` was not found.", t))); } } @@ -493,7 +493,7 @@ This is required so that you don't accidentally start meli and find out later th }; backends.validate_config(&lowercase_format, &mut s)?; if !s.extra.is_empty() { - return Err(MeliError::new(format!( + return Err(Error::new(format!( "Unrecognised configuration values: {:?}", s.extra ))); @@ -793,7 +793,7 @@ pub fn create_config_file(p: &Path) -> Result<()> { mod pp { //! Preprocess configuration files by unfolding `include` macros. use melib::{ - error::{MeliError, Result}, + error::{Error, Result}, parsec::*, ShellExpandTrait, }; @@ -860,7 +860,7 @@ mod pp { /// Expands `include` macros in path. fn pp_helper(path: &Path, level: u8) -> Result<String> { if level > 7 { - return Err(MeliError::new(format!("Maximum recursion limit reached while unfolding include directives in {}. Have you included a config file within itself?", path.display()))); + return Err(Error::new(format!("Maximum recursion limit reached while unfolding include directives in {}. Have you included a config file within itself?", path.display()))); } let mut contents = String::new(); let mut file = std::fs::File::open(path)?; @@ -869,7 +869,7 @@ mod pp { for (i, l) in contents.lines().enumerate() { if let (_, Some(sub_path)) = include_directive().parse(l).map_err(|l| { - MeliError::new(format!( + Error::new(format!( "Malformed include directive in line {} of file {}: {}\nConfiguration uses the standard m4 macro include(`filename`).", i, path.display(), @@ -936,7 +936,7 @@ mod dotaddressable { pub trait DotAddressable: Serialize { fn lookup(&self, parent_field: &str, path: &[&str]) -> Result<String> { if !path.is_empty() { - Err(MeliError::new(format!( + Err(Error::new(format!( "{} has no fields, it is of type {}", parent_field, std::any::type_name::<Self>() @@ -986,7 +986,7 @@ mod dotaddressable { "log_file" => self.log_file.lookup(field, tail), "maximum_level" => self.maximum_level.lookup(field, tail), - other => Err(MeliError::new(format!( + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), @@ -1008,13 +1008,13 @@ mod dotaddressable { "listing" => self.listing.lookup(field, tail), "notifications" => self.notifications.lookup(field, tail), "shortcuts" => self.shortcuts.lookup(field, tail), - "tags" => Err(MeliError::new("unimplemented")), - "composing" => Err(MeliError::new("unimplemented")), - "pgp" => Err(MeliError::new("unimplemented")), + "tags" => Err(Error::new("unimplemented")), + "composing" => Err(Error::new("unimplemented")), + "pgp" => Err(Error::new("unimplemented")), "terminal" => self.terminal.lookup(field, tail), "log" => self.log.lookup(field, tail), - other => Err(MeliError::new(format!( + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), @@ -1035,7 +1035,7 @@ mod dotaddressable { "conf" => self.conf.lookup(field, tail), "conf_override" => self.conf_override.lookup(field, tail), "mailbox_confs" => self.mailbox_confs.lookup(field, tail), - other => Err(MeliError::new(format!( + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), @@ -1052,17 +1052,17 @@ mod dotaddressable { Some(field) => { let _tail = &path[1..]; match *field { - "pager" => Err(MeliError::new("unimplemented")), //self.pager.lookup(field, tail), - "listing" => Err(MeliError::new("unimplemented")), // self.listing.lookup(field, tail), - "notifications" => Err(MeliError::new("unimplemented")), // self.notifications.lookup(field, tail), - "shortcuts" => Err(MeliError::new("unimplemented")), //self.shortcuts.lookup(field, tail), - "composing" => Err(MeliError::new("unimplemented")), //self.composing.lookup(field, tail), - "identity" => Err(MeliError::new("unimplemented")), //self.identity.lookup(field, tail)<String>, - "tags" => Err(MeliError::new("unimplemented")), //self.tags.lookup(field, tail), - "themes" => Err(MeliError::new("unimplemented")), //self.themes.lookup(field, tail)<Themes>, - "pgp" => Err(MeliError::new("unimplemented")), //self.pgp.lookup(field, tail), - - other => Err(MeliError::new(format!( + "pager" => Err(Error::new("unimplemented")), //self.pager.lookup(field, tail), + "listing" => Err(Error::new("unimplemented")), // self.listing.lookup(field, tail), + "notifications" => Err(Error::new("unimplemented")), // self.notifications.lookup(field, tail), + "shortcuts" => Err(Error::new("unimplemented")), //self.shortcuts.lookup(field, tail), + "composing" => Err(Error::new("unimplemented")), //self.composing.lookup(field, tail), + "identity" => Err(Error::new("unimplemented")), //self.identity.lookup(field, tail)<String>, + "tags" => Err(Error::new("unimplemented")), //self.tags.lookup(field, tail), + "themes" => Err(Error::new("unimplemented")), //self.themes.lookup(field, tail)<Themes>, + "pgp" => Err(Error::new("unimplemented")), //self.pgp.lookup(field, tail), + + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), @@ -1081,7 +1081,7 @@ mod dotaddressable { match *field { "conf_override" => self.conf_override.lookup(field, tail), "mailbox_conf" => self.mailbox_conf.lookup(field, tail), - other => Err(MeliError::new(format!( + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), @@ -1111,7 +1111,7 @@ mod dotaddressable { "conf_override" => self.conf_override.lookup(field, tail), "extra" => self.extra.lookup(field, tail), "order" => self.order.lookup(field, tail), - other => Err(MeliError::new(format!( + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), @@ -1138,7 +1138,7 @@ mod dotaddressable { "mailboxes" => self.mailboxes.lookup(field, tail), "manual_refresh" => self.manual_refresh.lookup(field, tail), "extra" => self.extra.lookup(field, tail), - other => Err(MeliError::new(format!( + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), @@ -1161,7 +1161,7 @@ mod dotaddressable { "ignore" => self.ignore.lookup(field, tail), "usage" => self.usage.lookup(field, tail), "extra" => self.extra.lookup(field, tail), - other => Err(MeliError::new(format!( + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), diff --git a/src/conf/accounts.rs b/src/conf/accounts.rs index 067a0c3d..ba0640c9 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::{ErrorKind, MeliError, Result}; +use melib::error::{ErrorKind, Error, Result}; use melib::text_processing::GlobMatch; use melib::thread::{SortField, SortOrder, Threads}; use melib::AddressBook; @@ -63,7 +63,7 @@ macro_rules! try_recv_timeout { let now = std::time::Instant::now(); let mut res = Ok(None); while now + _3_MS >= std::time::Instant::now() { - res = $oneshot.try_recv().map_err(|_| MeliError::new("canceled")); + res = $oneshot.try_recv().map_err(|_| Error::new("canceled")); if res.as_ref().map(|r| r.is_some()).unwrap_or(false) || res.is_err() { break; } @@ -75,7 +75,7 @@ macro_rules! try_recv_timeout { #[derive(Debug, Clone)] pub enum MailboxStatus { Available, - Failed(MeliError), + Failed(Error), /// first argument is done work, and second is total work Parsing(usize, usize), None, @@ -502,7 +502,7 @@ impl Account { is_online: if !backend.capabilities().is_remote { Ok(()) } else { - Err(MeliError::new("Attempting connection.")) + Err(Error::new("Attempting connection.")) }, mailbox_entries: Default::default(), mailboxes_order: Default::default(), @@ -1220,7 +1220,7 @@ impl Account { ), melib::INFO, ); - Err(MeliError::new(format!( + Err(Error::new(format!( "Message was stored in {} so that you can restore it manually.", file.path.display() )) @@ -1235,7 +1235,7 @@ impl Account { flags: Option<Flag>, ) -> Result<()> { if self.settings.account.read_only() { - return Err(MeliError::new(format!( + return Err(Error::new(format!( "Account {} is read-only.", self.name.as_str() ))); @@ -1275,7 +1275,7 @@ impl Account { match send_mail { SendMail::ShellCommand(ref command) => { if command.is_empty() { - return Err(MeliError::new( + return Err(Error::new( "send_mail shell command configuration value is empty", )); } @@ -1307,7 +1307,7 @@ impl Account { ) }; melib::log(&error_message, melib::LoggingLevel::ERROR); - return Err(MeliError::new(error_message).set_summary("Message not sent.")); + return Err(Error::new(error_message).set_summary("Message not sent.")); } Ok(None) } @@ -1342,7 +1342,7 @@ impl Account { self.insert_job(handle.job_id, JobRequest::SendMessageBackground { handle }); return Ok(None); } - Err(MeliError::new("Server does not support submission.") + Err(Error::new("Server does not support submission.") .set_summary("Message not sent.")) } } @@ -1362,7 +1362,7 @@ impl Account { match send_mail { SendMail::ShellCommand(ref command) => { if command.is_empty() { - return Err(MeliError::new( + return Err(Error::new( "send_mail shell command configuration value is empty", )); } @@ -1395,7 +1395,7 @@ impl Account { }; melib::log(&error_message, melib::LoggingLevel::ERROR); return Err( - MeliError::new(error_message).set_summary("Message not sent.") + Error::new(error_message).set_summary("Message not sent.") ); } Ok(()) @@ -1418,7 +1418,7 @@ impl Account { fut.await?; return Ok(()); } - Err(MeliError::new("Server does not support submission.") + Err(Error::new("Server does not support submission.") .set_summary("Message not sent.")) } } @@ -1444,7 +1444,7 @@ impl Account { ) -> Result<()> { use crate::command::actions::MailboxOperation; if self.settings.account.read_only() { - return Err(MeliError::new("Account is read-only.")); + return Err(Error::new("Account is read-only.")); } match op { MailboxOperation::Create(path) => { @@ -1463,7 +1463,7 @@ impl Account { } MailboxOperation::Delete(path) => { if self.mailbox_entries.len() == 1 { - return Err(MeliError::new("Cannot delete only mailbox.")); + return Err(Error::new("Cannot delete only mailbox.")); } let mailbox_hash = self.mailbox_by_path(&path)?; @@ -1526,8 +1526,8 @@ impl Account { ); Ok(()) } - MailboxOperation::Rename(_, _) => Err(MeliError::new("Not implemented.")), - MailboxOperation::SetPermissions(_) => Err(MeliError::new("Not implemented.")), + MailboxOperation::Rename(_, _) => Err(Error::new("Not implemented.")), + MailboxOperation::SetPermissions(_) => Err(Error::new("Not implemented.")), } } @@ -1614,7 +1614,7 @@ impl Account { { Ok(*mailbox_hash) } else { - Err(MeliError::new("Mailbox with that path not found.")) + Err(Error::new("Mailbox with that path not found.")) } } diff --git a/src/conf/listing.rs b/src/conf/listing.rs index 39951b20..2bf4b3db 100644 --- a/src/conf/listing.rs +++ b/src/conf/listing.rs @@ -21,7 +21,7 @@ use super::{default_vals::*, DotAddressable, IndexStyle}; use melib::search::Query; -use melib::{MeliError, Result}; +use melib::{Error, Result}; /// Settings for mail listings /// @@ -200,7 +200,7 @@ impl DotAddressable for ListingSettings { "selected_flag" => self.selected_flag.lookup(field, tail), "attachment_flag" => self.attachment_flag.lookup(field, tail), "thread_subject_pack" => self.thread_subject_pack.lookup(field, tail), - other => Err(MeliError::new(format!( + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), diff --git a/src/conf/notifications.rs b/src/conf/notifications.rs index d4c0bb3b..ea68a477 100644 --- a/src/conf/notifications.rs +++ b/src/conf/notifications.rs @@ -21,7 +21,7 @@ use super::default_vals::{internal_value_false, none, true_val}; use super::DotAddressable; -use melib::{MeliError, Result, ToggleFlag}; +use melib::{Error, Result, ToggleFlag}; /// Settings for the notifications function. #[derive(Debug, Serialize, Deserialize, Clone)] @@ -79,7 +79,7 @@ impl DotAddressable for NotificationsSettings { "xbiff_file_path" => self.xbiff_file_path.lookup(field, tail), "play_sound" => self.play_sound.lookup(field, tail), "sound_file" => self.sound_file.lookup(field, tail), - other => Err(MeliError::new(format!( + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), diff --git a/src/conf/pager.rs b/src/conf/pager.rs index cce1dd45..38efeace 100644 --- a/src/conf/pager.rs +++ b/src/conf/pager.rs @@ -24,7 +24,7 @@ use super::default_vals::*; use super::deserializers::*; use super::DotAddressable; -use melib::{MeliError, Result, ToggleFlag}; +use melib::{Error, Result, ToggleFlag}; /// Settings for the pager function. #[derive(Debug, Deserialize, Clone, Serialize)] @@ -149,7 +149,7 @@ impl DotAddressable for PagerSettings { } "show_date_in_my_timezone" => self.show_date_in_my_timezone.lookup(field, tail), "url_launcher" => self.html_filter.lookup(field, tail), - other => Err(MeliError::new(format!( + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), diff --git a/src/conf/shortcuts.rs b/src/conf/shortcuts.rs index fd23f871..4a3e8fdb 100644 --- a/src/conf/shortcuts.rs +++ b/src/conf/shortcuts.rs @@ -22,7 +22,7 @@ use super::DotAddressable; use crate::terminal::Key; use indexmap::IndexMap; -use melib::{MeliError, Result}; +use melib::{Error, Result}; #[macro_export] macro_rules! shortcut { @@ -76,7 +76,7 @@ impl DotAddressable for Shortcuts { "envelope_view" | "envelope-view" => self.envelope_view.lookup(field, tail), "thread_view" | "thread-view" => self.thread_view.lookup(field, tail), "pager" => self.pager.lookup(field, tail), - other => Err(MeliError::new(format!( + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), @@ -133,7 +133,7 @@ macro_rules! shortcut_key_values { let tail = &path[1..]; match *field { $(stringify!($fname) => self.$fname.lookup(field, tail),)* - other => Err(MeliError::new(format!( + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), diff --git a/src/conf/tags.rs b/src/conf/tags.rs index 728e17af..58559cdf 100644 --- a/src/conf/tags.rs +++ b/src/conf/tags.rs @@ -23,7 +23,7 @@ use super::DotAddressable; use crate::terminal::Color; -use melib::{MeliError, Result, TagHash}; +use melib::{Error, Result, TagHash}; use serde::{Deserialize, Deserializer}; use std::collections::{HashMap, HashSet}; @@ -85,7 +85,7 @@ impl DotAddressable for TagsSettings { match *field { "colors" => self.colors.lookup(field, tail), "ignore_tags" => self.ignore_tags.lookup(field, tail), - other => Err(MeliError::new(format!( + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), diff --git a/src/conf/terminal.rs b/src/conf/terminal.rs index 21c2b31b..57faafe6 100644 --- a/src/conf/terminal.rs +++ b/src/conf/terminal.rs @@ -24,7 +24,7 @@ use super::deserializers::non_empty_string; use super::DotAddressable; use super::Themes; -use melib::{MeliError, Result, ToggleFlag}; +use melib::{Error, Result, ToggleFlag}; /// Settings for terminal display #[derive(Debug, Deserialize, Clone, Serialize)] @@ -89,7 +89,7 @@ impl DotAddressable for TerminalSettings { let tail = &path[1..]; match *field { "theme" => self.theme.lookup(field, tail), - "themes" => Err(MeliError::new("unimplemented")), + "themes" => Err(Error::new("unimplemented")), "ascii_drawing" => self.ascii_drawing.lookup(field, tail), "use_color" => self.use_color.lookup(field, tail), "use_mouse" => self.use_mouse.lookup(field, tail), @@ -99,7 +99,7 @@ impl DotAddressable for TerminalSettings { "progress_spinner_sequence" => { self.progress_spinner_sequence.lookup(field, tail) } - other => Err(MeliError::new(format!( + other => Err(Error::new(format!( "{} has no field named {}", parent_field, other ))), diff --git a/src/conf/themes.rs b/src/conf/themes.rs index 7c6da737..905b2293 100644 --- a/src/conf/themes.rs +++ b/src/conf/themes.rs @@ -31,7 +31,7 @@ use crate::terminal::{Attr, Color}; use crate::Context; use indexmap::IndexMap; -use melib::{MeliError, Result}; +use melib::{Error, Result}; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use smallvec::SmallVec; use std::borrow::Cow; @@ -1212,20 +1212,20 @@ impl Themes { Themes::validate_keys(name, t, &hash_set)?; } if let Err(err) = is_cyclic(&self.light) { - return Err(MeliError::new(format!( + return Err(Error::new(format!( "light theme contains a cycle: {}", err ))); } if let Err(err) = is_cyclic(&self.dark) { - return Err(MeliError::new(format!( + return Err(Error::new(format!( "dark theme contains a cycle: {}", err ))); } for (k, t) in self.other_themes.iter() { if let Err(err) = is_cyclic(t) { - return Err(MeliError::new(format!( + return Err(Error::new(format!( "{} theme contains a cycle: {}", k, err ))); diff --git a/src/mailcap.rs b/src/mailcap.rs index c3caa55f..62a3552e 100644 --- a/src/mailcap.rs +++ b/src/mailcap.rs @@ -26,7 +26,7 @@ use crate::state::Context; use crate::types::{create_temp_file, ForkType, UIEvent}; use melib::text_processing::GlobMatch; -use melib::{email::Attachment, MeliError, Result}; +use melib::{email::Attachment, Error, Result}; use std::collections::HashMap; use std::io::Read; use std::io::Write; @@ -45,13 +45,13 @@ impl MailcapEntry { * $XDG_CONFIG_HOME/meli/mailcap:$XDG_CONFIG_HOME/.mailcap:$HOME/.mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap */ let xdg_dirs = - xdg::BaseDirectories::with_prefix("meli").map_err(|e| MeliError::new(e.to_string()))?; + xdg::BaseDirectories::with_prefix("meli").map_err(|e| Error::new(e.to_string()))?; let mut mailcap_path = xdg_dirs .place_config_file("mailcap") - .map_err(|e| MeliError::new(e.to_string()))?; + .map_err(|e| Error::new(e.to_string()))?; if !mailcap_path.exists() { mailcap_path = xdg::BaseDirectories::new() - .map_err(|e| MeliError::new(e.to_string()))? + .map_err(|e| Error::new(e.to_string()))? .place_config_file("mailcap")?; if !mailcap_path.exists() { if let Ok(home) = std::env::var("HOME") { @@ -65,7 +65,7 @@ impl MailcapEntry { mailcap_path = PathBuf::from("/usr/local/etc/mailcap"); } if !mailcap_path.exists() { - return Err(MeliError::new("No mailcap file found.")); + return Err(Error::new("No mailcap file found.")); } } } @@ -140,7 +140,7 @@ impl MailcapEntry { } match result { - None => Err(MeliError::new("Not found")), + None => Err(Error::new("Not found")), Some(MailcapEntry { command, copiousoutput, diff --git a/src/main.rs b/src/main.rs index 1423802f..8fbceeb8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -78,7 +78,7 @@ fn parse_manpage(src: &str) -> Result<ManPages> { "meli.7" | "guide" => Ok(ManPages::Guide), "meli.conf" | "meli.conf.5" | "conf" | "config" | "configuration" => Ok(ManPages::Conf), "meli-themes" | "meli-themes.5" | "themes" | "theming" | "theme" => Ok(ManPages::Themes), - _ => Err(MeliError::new(format!( + _ => Err(Error::new(format!( "Invalid documentation page: {}", src ))), @@ -188,7 +188,7 @@ fn run_app(opt: Opt) -> Result<()> { crate::conf::get_config_file()? }; if config_path.exists() { - return Err(MeliError::new(format!( + return Err(Error::new(format!( "File `{}` already exists.\nMaybe you meant to specify another path?", config_path.display() ))); @@ -247,7 +247,7 @@ fn run_app(opt: Opt) -> Result<()> { } #[cfg(not(feature = "cli-docs"))] Some(SubCommand::Man(_manopt)) => { - return Err(MeliError::new("error: this version of meli was not build with embedded documentation (cargo feature `cli-docs`). You might have it installed as manpages (eg `man meli`), otherwise check https://meli.delivery")); + return Err(Error::new("error: this version of meli was not build with embedded documentation (cargo feature `cli-docs`). You might have it installed as manpages (eg `man meli`), otherwise check https://meli.delivery")); } Some(SubCommand::CompiledWith) => { #[cfg(feature = "notmuch")] @@ -279,12 +279,12 @@ fn run_app(opt: Opt) -> Result<()> { } Some(SubCommand::View { ref path }) => { if !path.exists() { - return Err(MeliError::new(format!( + return Err(Error::new(format!( "`{}` is not a valid path", path.display() ))); } else if !path.is_file() { - return Err(MeliError::new(format!( + return Err(Error::new(format!( "`{}` is a directory", path.display() ))); diff --git a/src/plugins.rs b/src/plugins.rs index c0bbdae0..6fb0b98d 100644 --- a/src/plugins.rs +++ b/src/plugins.rs @@ -21,7 +21,7 @@ /*! Plugins are executed by meli and communication is done by `messagepack` IPC. */ -use melib::error::{MeliError, Result}; +use melib::error::{Error, Result}; use std::collections::HashMap; use std::io::Write; use std::os::unix::net::{UnixListener, UnixStream}; @@ -276,7 +276,7 @@ impl PluginManager { } } } - Err(MeliError::new("no listeners for this hook")) + Err(Error::new("no listeners for this hook")) } pub fn listener(&self) -> UnixListener { diff --git a/src/plugins/backend.rs b/src/plugins/backend.rs index bdc69574..8efa90fe 100644 --- a/src/plugins/backend.rs +++ b/src/plugins/backend.rs @@ -24,7 +24,7 @@ use melib::async_workers::{Async, AsyncBuilder, AsyncStatus, WorkContext}; use melib::backends::*; use melib::conf::AccountSettings; use melib::email::{Envelope, EnvelopeHash, Flag}; -use melib::error::{MeliError, Result}; +use melib::error::{Error, Result}; use std::collections::BTreeMap; use std::collections::HashMap; use std::sync::{Arc, Mutex, RwLock}; @@ -90,7 +90,7 @@ impl MailBackend for PluginBackend { } is_online.1.clone() } else { - Err(MeliError::new("busy")) + Err(Error::new("busy")) } } @@ -201,13 +201,13 @@ impl MailBackend for PluginBackend { _mailbox_hash: MailboxHash, _flags: Option<Flag>, ) -> ResultFuture<()> { - Err(MeliError::new("Saving is currently unimplemented for plugins")) + Err(Error::new("Saving is currently unimplemented for plugins")) } fn create_mailbox( &mut self, _name: String, ) -> ResultFuture<(MailboxHash, HashMap<MailboxHash, Mailbox>)> { - Err(MeliError::new("Creating a mailbox is currently unimplemented for plugins")) + Err(Error::new("Creating a mailbox is currently unimplemented for plugins")) } fn collection(&self) -> melib::Collection { self.collection.clone() @@ -226,7 +226,7 @@ impl PluginBackend { _ev: melib::backends::BackendEventConsumer, ) -> Result<Box<dyn MailBackend>> { if plugin.kind != PluginKind::Backend { - return Err(MeliError::new(format!( + return Err(Error::new(format!( "Error: Plugin `{}` is not a mail backend plugin, it's `{:?}`", &plugin.name, &plugin.kind ))); @@ -248,7 +248,7 @@ impl PluginBackend { plugin, channel: Arc::new(Mutex::new(channel)), collection: Default::default(), - is_online: Arc::new(Mutex::new((now, Err(MeliError::new("Unitialized"))))), + is_online: Arc::new(Mutex::new((now, Err(Error::new("Unitialized"))))), })) } @@ -294,12 +294,12 @@ impl BackendOp for PluginOp { .and_then(std::convert::identity)? .into_bytes()) } else { - Err(MeliError::new("busy")) + Err(Error::new("busy")) } })) } fn fetch_flags(&self) -> ResultFuture<Flag> { - Err(MeliError::new("Unimplemented.")) + Err(Error::new("Unimplemented.")) } } diff --git a/src/plugins/rpc.rs b/src/plugins/rpc.rs index 1195dfc6..bf2e045d 100644 --- a/src/plugins/rpc.rs +++ b/src/plugins/rpc.rs @@ -40,7 +40,7 @@ impl RpcChannel { session: *session, }; let greeting: PluginGreeting = ret.from_read().map_err(|err| { - MeliError::new(format!("Could not get correct plugin greeting: {}", err)) + Error::new(format!("Could not get correct plugin greeting: {}", err)) })?; debug!(&greeting); //if greeting.version != "dev" { @@ -54,11 +54,11 @@ impl RpcChannel { pub fn expect_ack(&mut self) -> Result<()> { debug!("expect_ack()"); let ack: u32 = debug!(rmp_serde::decode::from_read(&mut self.stream)) - .map_err(|_| MeliError::new("Plugin did not return ACK."))?; + .map_err(|_| Error::new("Plugin did not return ACK."))?; if 0x6 == ack { Ok(()) } else { - Err(MeliError::new("Plugin did not return ACK.")) + Err(Error::new("Plugin did not return ACK.")) } } @@ -68,7 +68,7 @@ impl RpcChannel { &mut self.stream, &rmpv::ValueRef::Integer(0x6.into()) )) - .map_err(|err| MeliError::new(err.to_string()))?; + .map_err(|err| Error::new(err.to_string()))?; let _ = self.stream.flush(); Ok(()) } @@ -76,7 +76,7 @@ impl RpcChannel { pub fn write_ref(&mut self, value_ref: &rmpv::ValueRef) -> Result<()> { debug!("write_ref() {:?}", value_ref); debug!(rmpv::encode::write_value_ref(&mut self.stream, value_ref)) - .map_err(|err| MeliError::new(err.to_string()))?; + .map_err(|err| Error::new(err.to_string()))?; let _ = self.stream.flush(); Ok(()) } @@ -84,7 +84,7 @@ impl RpcChannel { pub fn read(&mut self) -> Result<rmpv::Value> { debug!("read()"); let ret: RpcResult = debug!(rmp_serde::decode::from_read(&mut self.stream)) - .map_err(|err| MeliError::new(err.to_string()))?; + .map_err(|err| Error::new(err.to_string()))?; let _ = self.stream.flush(); self.ack()?; debug!("read() ret={:?}", &ret); @@ -97,7 +97,7 @@ impl RpcChannel { { debug!("from_read()"); let ret: Result<T> = debug!(rmp_serde::decode::from_read(&mut self.stream)) - .map_err(|err| MeliError::new(err.to_string())); + .map_err(|err| Error::new(err.to_string())); let _ = self.stream.flush(); self.ack()?; debug!("read() ret={:?}", &ret); @@ -117,7 +117,7 @@ impl RpcResult { fn into(self) -> Result<rmpv::Value> { match self { RpcResult::Ok(v) => Ok(v), - RpcResult::Err(err) => Err(MeliError::new(err)), + RpcResult::Err(err) => Err(Error::new(err)), } } } @@ -136,7 +136,7 @@ impl<T: core::fmt::Debug + Clone + serde::Serialize + serde::de::DeserializeOwne fn into(self) -> Result<T> { match self { PluginResult::Ok(v) => Ok(v), - PluginResult::Err(err) => Err(MeliError::new(err)), + PluginResult::Err(err) => Err(Error::new(err)), } } } diff --git a/src/sqlite3.rs b/src/sqlite3.rs index deecf295..4348cd15 100644 --- a/src/sqlite3.rs +++ b/src/sqlite3.rs @@ -21,7 +21,7 @@ /*! Use an sqlite3 database for fast searching. */ -use crate::melib::ResultIntoMeliError; +use crate::melib::ResultIntoError; use melib::search::{ escape_double_quote, Query::{self, *}, @@ -32,7 +32,7 @@ use melib::{ log, sqlite3::{self as melib_sqlite3, rusqlite::params, DatabaseDescription}, thread::{SortField, SortOrder}, - MeliError, Result, ERROR, + Error, Result, ERROR, }; use smallvec::SmallVec; @@ -142,7 +142,7 @@ pub async fn insert( ) -> Result<()> { let db_path = db_path()?; if !db_path.exists() { - return Err(MeliError::new( + return Err(Error::new( "Database hasn't been initialised. Run `reindex` command", )); } @@ -195,7 +195,7 @@ pub async fn insert( ), ERROR, ); - return Err(MeliError::new(err.to_string())); + return Err(Error::new(err.to_string())); } let account_id: i32 = { let mut stmt = conn @@ -214,7 +214,7 @@ pub async fn insert( VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15)", params![account_id, envelope.hash().to_be_bytes().to_vec(), envelope.date_as_str(), envelope.field_from_to_string(), envelope.field_to_to_string(), envelope.field_cc_to_string(), envelope.field_bcc_to_string(), envelope.subject().into_owned().trim_end_matches('\u{0}'), envelope.message_id_display().to_string(), envelope.in_reply_to_display().map(|f| f.to_string()).unwrap_or_default(), envelope.field_references_to_string(), i64::from(envelope.flags().bits()), if envelope.has_attachments() { 1 } else { 0 }, body, envelope.date().to_be_bytes().to_vec()], ) - .map_err(|e| MeliError::new(e.to_string())) { + .map_err(|e| Error::new(e.to_string())) { debug!( "Failed to insert envelope {}: {}", envelope.message_id_display(), @@ -235,7 +235,7 @@ pub async fn insert( pub fn remove(env_hash: EnvelopeHash) -> Result<()> { let db_path = db_path()?; if !db_path.exists() { - return Err(MeliError::new( + return Err(Error::new( "Database hasn't been initialised. Run `reindex` command", )); } @@ -246,7 +246,7 @@ pub fn remove(env_hash: EnvelopeHash) -> Result<()> { "DELETE FROM envelopes WHERE hash = ?", params![env_hash.to_be_bytes().to_vec(),], ) - .map_err(|e| MeliError::new(e.to_string())) + .map_err(|e| Error::new(e.to_string())) { debug!("Failed to remove envelope {}: {}", env_hash, err); log( @@ -332,7 +332,7 @@ pub fn search( ) -> ResultFuture<SmallVec<[EnvelopeHash; 512]>> { let db_path = db_path()?; if !db_path.exists() { - return Err(MeliError::new( + return Err(Error::new( "Database hasn't been initialised. Run `reindex` command", )); } @@ -359,12 +359,12 @@ pub fn search( )) .as_str(), ) - .map_err(|e| MeliError::new(e.to_string()))?; + .map_err(|e| Error::new(e.to_string()))?; let results = stmt .query_map([], |row| row.get::<_, EnvelopeHash>(0)) - .map_err(MeliError::from)? - .map(|item| item.map_err(MeliError::from)) + .map_err(Error::from)? + .map(|item| item.map_err(Error::from)) .collect::<Result<SmallVec<[EnvelopeHash; 512]>>>(); Ok(Box::pin(async { results })) } diff --git a/src/state.rs b/src/state.rs index 856c7906..b9e7aefb 100644 --- a/src/state.rs +++ b/src/state.rs @@ -421,7 +421,7 @@ impl State { s.context.accounts[i].watch(); } if s.context.is_online_idx(i).is_ok() && s.context.accounts[i].is_empty() { - //return Err(MeliError::new(format!( + //return Err(Error::new(format!( // "Account {} has no mailboxes configured.", // s.context.accounts[i].name() //))); diff --git a/src/terminal/embed/grid.rs b/src/terminal/embed/grid.rs index baa63fdb..1e5cfc87 100644 --- a/src/terminal/embed/grid.rs +++ b/src/terminal/embed/grid.rs @@ -21,7 +21,7 @@ use super::*; use crate::terminal::{cells::*, Color}; -use melib::error::{MeliError, Result}; +use melib::error::{Error, Result}; use melib::text_processing::wcwidth; use nix::sys::wait::WaitStatus; use nix::sys::wait::{waitpid, WaitPidFlag}; @@ -164,7 +164,7 @@ impl EmbedTerminal { pub fn is_active(&self) -> Result<WaitStatus> { debug!(waitpid(self.child_pid, Some(WaitPidFlag::WNOHANG),)) - .map_err(|e| MeliError::new(e.to_string())) + .map_err(|e| Error::new(e.to_string())) } pub fn process_byte(&mut self, byte: u8) { |