diff --git a/melib/src/backends/imap/protocol_parser.rs b/melib/src/backends/imap/protocol_parser.rs index 17bedff6d..9c92768c5 100644 --- a/melib/src/backends/imap/protocol_parser.rs +++ b/melib/src/backends/imap/protocol_parser.rs @@ -619,7 +619,7 @@ pub fn select_response(input: &str) -> Result { Ok(ret) } else { debug!("BAD/NO response in select: {}", input); - Err(MeliError::new(input)) + Err(MeliError::new(input.to_string())) } } diff --git a/melib/src/error.rs b/melib/src/error.rs index 47fd22035..49464e816 100644 --- a/melib/src/error.rs +++ b/melib/src/error.rs @@ -37,14 +37,14 @@ pub type Result = result::Result; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct MeliError { - pub summary: Option, - pub details: String, + pub summary: Option>, + pub details: Cow<'static, str>, } impl MeliError { pub fn new(msg: M) -> MeliError where - M: Into, + M: Into>, { MeliError { summary: None, @@ -54,7 +54,7 @@ impl MeliError { pub fn set_summary(mut self, summary: M) -> MeliError where - M: Into, + M: Into>, { self.summary = Some(summary.into()); self @@ -69,7 +69,7 @@ impl fmt::Display for MeliError { impl Into for MeliError { fn into(self) -> String { - self.details + self.details.into() } } @@ -82,7 +82,7 @@ impl Error for MeliError { impl From for MeliError { #[inline] fn from(kind: io::Error) -> MeliError { - MeliError::new(kind.description()) + MeliError::new(kind.description().to_string()) } } diff --git a/ui/src/components/mail/compose.rs b/ui/src/components/mail/compose.rs index e1a492caa..0c3a42ade 100644 --- a/ui/src/components/mail/compose.rs +++ b/ui/src/components/mail/compose.rs @@ -1228,8 +1228,8 @@ pub fn save_draft( context.accounts[account_cursor].save_special(bytes, folder_type, flags) { context.replies.push_back(UIEvent::Notification( - summary, - details, + summary.map(|s| s.into()), + details.into(), Some(NotificationType::ERROR), )); } diff --git a/ui/src/mailcap.rs b/ui/src/mailcap.rs index 7bf304740..b712e0a7d 100644 --- a/ui/src/mailcap.rs +++ b/ui/src/mailcap.rs @@ -135,7 +135,7 @@ impl MailcapEntry { } match result { - None => Err(MeliError::new("Not found".to_string())), + None => Err(MeliError::new("Not found")), Some(MailcapEntry { command, copiousoutput,