diff --git a/src/secret.rs b/src/secret.rs index ec4aa8f0..1c7a6759 100644 --- a/src/secret.rs +++ b/src/secret.rs @@ -64,7 +64,7 @@ pub enum SecretError { } impl UserFacingError for SecretError { - fn to_user_facing(self) -> String { + fn to_user_facing(&self) -> String { match self { SecretError::UnsupportedVersion { version, .. } => gettext_f( // Translators: Do NOT translate the content between '{' and '}', this is a @@ -72,7 +72,7 @@ impl UserFacingError for SecretError { "Found stored session with unsupported version {version_nb}", &[("version_nb", &version.to_string())], ), - SecretError::Invalid(error) => error, + SecretError::Invalid(error) => error.clone(), SecretError::Oo7(error) => error.to_user_facing(), error => error.to_string(), } @@ -80,7 +80,7 @@ impl UserFacingError for SecretError { } impl UserFacingError for oo7::Error { - fn to_user_facing(self) -> String { + fn to_user_facing(&self) -> String { match self { oo7::Error::Portal(error) => error.to_user_facing(), oo7::Error::DBus(error) => error.to_user_facing(), @@ -89,7 +89,7 @@ impl UserFacingError for oo7::Error { } impl UserFacingError for oo7::portal::Error { - fn to_user_facing(self) -> String { + fn to_user_facing(&self) -> String { match self { oo7::portal::Error::FileHeaderMismatch(_) | oo7::portal::Error::VersionMismatch(_) | @@ -129,7 +129,7 @@ impl UserFacingError for oo7::portal::Error { } impl UserFacingError for oo7::dbus::Error { - fn to_user_facing(self) -> String { + fn to_user_facing(&self) -> String { match self { oo7::dbus::Error::Deleted => gettext( "The item was deleted.", diff --git a/src/user_facing_error.rs b/src/user_facing_error.rs index cda60c80..19a00a93 100644 --- a/src/user_facing_error.rs +++ b/src/user_facing_error.rs @@ -13,11 +13,11 @@ use matrix_sdk::{ use crate::ngettext_f; pub trait UserFacingError { - fn to_user_facing(self) -> String; + fn to_user_facing(&self) -> String; } impl UserFacingError for HttpError { - fn to_user_facing(self) -> String { + fn to_user_facing(&self) -> String { match self { HttpError::Reqwest(error) => { // TODO: Add more information based on the error @@ -54,7 +54,7 @@ impl UserFacingError for HttpError { _ => { // TODO: The server may not give us pretty enough error message. We should // add our own error message. - message + message.clone() } } } @@ -64,7 +64,7 @@ impl UserFacingError for HttpError { } impl UserFacingError for Error { - fn to_user_facing(self) -> String { + fn to_user_facing(&self) -> String { match self { Error::DecryptorError(_) => gettext("Could not decrypt the event"), Error::Http(http_error) => http_error.to_user_facing(), @@ -74,7 +74,7 @@ impl UserFacingError for Error { } impl UserFacingError for ClientBuildError { - fn to_user_facing(self) -> String { + fn to_user_facing(&self) -> String { match self { ClientBuildError::Url(_) => gettext("This is not a valid URL"), ClientBuildError::AutoDiscovery(_) => { diff --git a/src/utils/matrix.rs b/src/utils/matrix.rs index 91d69334..e3e8f180 100644 --- a/src/utils/matrix.rs +++ b/src/utils/matrix.rs @@ -160,7 +160,7 @@ pub enum ClientSetupError { } impl UserFacingError for ClientSetupError { - fn to_user_facing(self) -> String { + fn to_user_facing(&self) -> String { match self { ClientSetupError::Client(err) => err.to_user_facing(), ClientSetupError::Sdk(err) => err.to_user_facing(),