diff --git a/crates/matrix-sdk-base/src/error.rs b/crates/matrix-sdk-base/src/error.rs index e67b6ebe1..3ce40488b 100644 --- a/crates/matrix-sdk-base/src/error.rs +++ b/crates/matrix-sdk-base/src/error.rs @@ -26,6 +26,7 @@ use thiserror::Error; pub type Result = std::result::Result; /// Internal representation of errors. +#[non_exhaustive] #[derive(Error, Debug)] pub enum Error { /// Queried endpoint requires authentication but was called on an anonymous diff --git a/crates/matrix-sdk-sled/Cargo.toml b/crates/matrix-sdk-sled/Cargo.toml index 8881ca3fb..bcd434a54 100644 --- a/crates/matrix-sdk-sled/Cargo.toml +++ b/crates/matrix-sdk-sled/Cargo.toml @@ -5,10 +5,13 @@ edition = "2021" rust-version = "1.60" [features] -default = ["state-store", "crypto-store"] +default = ["state-store"] state-store = ["matrix-sdk-base"] -crypto-store = ["matrix-sdk-crypto"] +crypto-store = [ + "matrix-sdk-crypto", + "matrix-sdk-base?/e2e-encryption", +] [dependencies] futures-core = "0.3.15" diff --git a/crates/matrix-sdk/src/error.rs b/crates/matrix-sdk/src/error.rs index 156217e9a..a4373b0f2 100644 --- a/crates/matrix-sdk/src/error.rs +++ b/crates/matrix-sdk/src/error.rs @@ -99,6 +99,7 @@ pub enum HttpError { /// Internal representation of errors. #[derive(Error, Debug)] +#[non_exhaustive] pub enum Error { /// Error doing an HTTP request. #[error(transparent)] @@ -168,6 +169,25 @@ pub enum Error { #[cfg(feature = "image-proc")] #[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. + /// this might happen because encryption was enabled on the base-crate + /// but not here and that raised. + #[error("unknown error: {0}")] + UnknownError(String), } /// Error for the room key importing functionality. @@ -261,6 +281,12 @@ impl From for Error { SdkBaseError::OlmError(e) => Self::OlmError(e), #[cfg(feature = "e2e-encryption")] SdkBaseError::MegolmError(e) => Self::MegolmError(e), + #[cfg(feature = "eyre")] + _ => Self::OtherEyreReport(eyre::eyre!(e)), + #[cfg(all(not(feature = "eyre"), feature = "anyhow"))] + _ => Self::OtherAnyhowError(anyhow::anyhow!(e)), + #[cfg(all(not(feature = "eyre"), not(feature = "anyhow")))] + _ => Self::UnknownError(format!("{:?}", e)), } } }