Replace erroneous use of set_err_kind with set_kind

set_err_kind() is a method of the IntoError trait, not an Error method;
it is meant to be used for any error type that can be converted into
Error. Since melib::Error implements Into<melib::Error> tautologically,
this was not a compilation error. Nevertheless, the correct thing to do
is use the type method directly to set ErrorKind.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
This commit is contained in:
Manos Pitsidianakis 2024-02-11 16:29:37 +02:00
parent c332c2f5ff
commit 873a67d0fb
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0
5 changed files with 16 additions and 13 deletions

View File

@ -131,7 +131,7 @@ pub fn pipe() -> Result<(OwnedFd, OwnedFd)> {
.set_source(Some( .set_source(Some(
(Box::new(err) as Box<dyn std::error::Error + Send + Sync + 'static>).into(), (Box::new(err) as Box<dyn std::error::Error + Send + Sync + 'static>).into(),
)) ))
.set_err_kind(ErrorKind::OSError) .set_kind(ErrorKind::OSError)
}) })
} }

View File

@ -49,7 +49,7 @@ use crate::{
pgp::{DecryptionMetadata, Recipient}, pgp::{DecryptionMetadata, Recipient},
Address, Address,
}, },
error::{Error, ErrorKind, IntoError, Result, ResultIntoError}, error::{Error, ErrorKind, Result, ResultIntoError},
}; };
macro_rules! call { macro_rules! call {
@ -557,7 +557,7 @@ impl Context {
return Err(Error::new( return Err(Error::new(
"Unspecified libgpgme error: gpgme_op_verify_result returned NULL.", "Unspecified libgpgme error: gpgme_op_verify_result returned NULL.",
) )
.set_err_kind(ErrorKind::External)); .set_kind(ErrorKind::External));
} }
} }
let io_state_lck = io_state.lock().unwrap(); let io_state_lck = io_state.lock().unwrap();
@ -914,7 +914,7 @@ impl Context {
return Err(Error::new( return Err(Error::new(
"Unspecified libgpgme error: gpgme_op_decrypt_result returned NULL.", "Unspecified libgpgme error: gpgme_op_decrypt_result returned NULL.",
) )
.set_err_kind(ErrorKind::External)); .set_kind(ErrorKind::External));
} }
let mut recipients = vec![]; let mut recipients = vec![];
let is_mime; let is_mime;
@ -1123,7 +1123,7 @@ impl Context {
return Err(Error::new( return Err(Error::new(
"Unspecified libgpgme error: gpgme_op_encrypt_result returned NULL.", "Unspecified libgpgme error: gpgme_op_encrypt_result returned NULL.",
) )
.set_err_kind(ErrorKind::External)); .set_kind(ErrorKind::External));
} }
/* Rewind cursor */ /* Rewind cursor */
cipher cipher

View File

@ -368,7 +368,7 @@ impl ImapStream {
"Could not connect to {}: server does not accept logins [LOGINDISABLED]", "Could not connect to {}: server does not accept logins [LOGINDISABLED]",
&server_conf.server_hostname &server_conf.server_hostname
)) ))
.set_err_kind(ErrorKind::Authentication)); .set_kind(ErrorKind::Authentication));
} }
(uid_store.event_consumer)( (uid_store.event_consumer)(
@ -395,7 +395,7 @@ impl ImapStream {
.collect::<Vec<String>>() .collect::<Vec<String>>()
.join(" ") .join(" ")
)) ))
.set_err_kind(ErrorKind::Authentication)); .set_kind(ErrorKind::Authentication));
} }
let xoauth2 = base64::decode(&server_conf.server_password) let xoauth2 = base64::decode(&server_conf.server_password)
.chain_err_summary(|| { .chain_err_summary(|| {
@ -442,7 +442,7 @@ impl ImapStream {
"Could not connect. Server replied with '{}'", "Could not connect. Server replied with '{}'",
String::from_utf8_lossy(l[tag_start.len()..].trim()) String::from_utf8_lossy(l[tag_start.len()..].trim())
)) ))
.set_err_kind(ErrorKind::Authentication)); .set_kind(ErrorKind::Authentication));
} }
should_break = true; should_break = true;
} }

View File

@ -263,7 +263,7 @@ impl NntpStream {
"Could not connect: no supported auth mechanisms in server capabilities: {:?}", "Could not connect: no supported auth mechanisms in server capabilities: {:?}",
capabilities capabilities
)) ))
.set_err_kind(ErrorKind::Authentication)); .set_kind(ErrorKind::Authentication));
} }
} }
@ -335,7 +335,7 @@ impl NntpStream {
|| ret.starts_with("401 ") || ret.starts_with("401 ")
{ {
return Err(Error::new(format!("Connection state error: {}", ret)) return Err(Error::new(format!("Connection state error: {}", ret))
.set_err_kind(ErrorKind::Authentication)); .set_kind(ErrorKind::Authentication));
} else if !expected_reply_code.iter().any(|r| ret.starts_with(r)) { } else if !expected_reply_code.iter().any(|r| ret.starts_with(r)) {
return Err(Error::new(format!("Unexpected reply code: {}", ret))); return Err(Error::new(format!("Unexpected reply code: {}", ret)));
} }

View File

@ -210,16 +210,19 @@ impl std::ops::Not for SortOrder {
pub mod hostname { pub mod hostname {
//! Get local hostname. //! Get local hostname.
use crate::error::{Error, ErrorKind, IntoError, Result};
use crate::src_err_arc_wrap;
use std::io::Read; use std::io::Read;
use crate::{
error::{Error, ErrorKind, Result},
src_err_arc_wrap,
};
/// Get local hostname with the `gethostname()` libc function. /// Get local hostname with the `gethostname()` libc function.
pub fn hostname() -> Result<std::ffi::OsString> { pub fn hostname() -> Result<std::ffi::OsString> {
let retval = nix::unistd::gethostname().map_err(|err| { let retval = nix::unistd::gethostname().map_err(|err| {
Error::new("Could not discover local hostname") Error::new("Could not discover local hostname")
.set_source(Some(src_err_arc_wrap! {err})) .set_source(Some(src_err_arc_wrap! {err}))
.set_err_kind(ErrorKind::OSError) .set_kind(ErrorKind::OSError)
}); });
if retval.is_err() { if retval.is_err() {
let mut hostn_buf = String::with_capacity(256); let mut hostn_buf = String::with_capacity(256);