From 2db1bc75c1f0924209907cc2cdaf980b4f9fc401 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Tue, 24 Jan 2023 15:02:59 +0000 Subject: [PATCH] Expose MissingRoomKey decryption error --- bindings/matrix-sdk-crypto-ffi/src/error.rs | 15 +++++++++++++-- bindings/matrix-sdk-crypto-ffi/src/olm.udl | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bindings/matrix-sdk-crypto-ffi/src/error.rs b/bindings/matrix-sdk-crypto-ffi/src/error.rs index 273e05900..8017481ee 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/error.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/error.rs @@ -59,8 +59,19 @@ pub enum DecryptionError { Serialization(#[from] serde_json::Error), #[error(transparent)] Identifier(#[from] IdParseError), - #[error(transparent)] - Megolm(#[from] MegolmError), + #[error("Megolm decryption error: {error_message}")] + Megolm { error_message: String }, + #[error("Can't find the room key to decrypt the event")] + MissingRoomKey, #[error(transparent)] Store(#[from] InnerStoreError), } + +impl From for DecryptionError { + fn from(value: MegolmError) -> Self { + match value { + MegolmError::MissingRoomKey => Self::MissingRoomKey, + _ => Self::Megolm { error_message: value.to_string() }, + } + } +} diff --git a/bindings/matrix-sdk-crypto-ffi/src/olm.udl b/bindings/matrix-sdk-crypto-ffi/src/olm.udl index 8c489e3d8..fc5af2038 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/olm.udl +++ b/bindings/matrix-sdk-crypto-ffi/src/olm.udl @@ -59,6 +59,7 @@ enum DecryptionError { "Identifier", "Serialization", "Megolm", + "MissingRoomKey", "Store", };