From e3016482e1d2fdfb2e68f966254d5dbcb37cf9d8 Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Tue, 3 May 2022 10:28:28 +0200 Subject: [PATCH] fix: Simplify UnknownError in SDK --- crates/matrix-sdk/src/error.rs | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/crates/matrix-sdk/src/error.rs b/crates/matrix-sdk/src/error.rs index 017cf7ade..5c533aea8 100644 --- a/crates/matrix-sdk/src/error.rs +++ b/crates/matrix-sdk/src/error.rs @@ -176,24 +176,11 @@ pub enum Error { #[error(transparent)] ImageError(#[from] ImageError), - /// An other error was raised and formatted with eyre - /// this might happen because encryption was enabled on the base-crate - /// but not here and that raised. - #[cfg(feature = "eyre")] - OtherEyreReport(eyre::Report), - - /// An other error was raised and formatted with anyhow - /// this might happen because encryption was enabled on the base-crate - /// but not here and that raised. - #[cfg(feature = "anyhow")] - OtherAnyhowError(anyhow::Error), - - /// An other error was raised and neither eyre, nor anyhow were activated - /// so it's Debug information was formatted as a String. + /// An other error was raised /// this might happen because encryption was enabled on the base-crate /// but not here and that raised. #[error("unknown error: {0}")] - UnknownError(String), + UnknownError(Box), } /// Error for the room key importing functionality. @@ -300,11 +287,14 @@ impl From for Error { #[cfg(feature = "e2e-encryption")] SdkBaseError::MegolmError(e) => Self::MegolmError(e), #[cfg(feature = "eyre")] - _ => Self::OtherEyreReport(eyre::eyre!(e)), + _ => Self::UnknownError(eyre::eyre!(e).into()), #[cfg(all(not(feature = "eyre"), feature = "anyhow"))] - _ => Self::OtherAnyhowError(anyhow::anyhow!(e)), + _ => Self::UnknownError(anyhow::anyhow!(e).into()), #[cfg(all(not(feature = "eyre"), not(feature = "anyhow")))] - _ => Self::UnknownError(format!("{:?}", e)), + _ => { + let e: Box = format!("{:?}", e).into(); + Self::UnknownError(e) + } } } }