diff --git a/bindings/matrix-sdk-ffi/src/error.rs b/bindings/matrix-sdk-ffi/src/error.rs index 675d1d93d98..f5ced043248 100644 --- a/bindings/matrix-sdk-ffi/src/error.rs +++ b/bindings/matrix-sdk-ffi/src/error.rs @@ -1,8 +1,9 @@ use std::fmt::Display; use matrix_sdk::{ - encryption::CryptoStoreError, event_cache::EventCacheError, oidc::OidcError, HttpError, - IdParseError, NotificationSettingsError as SdkNotificationSettingsError, StoreError, + encryption::CryptoStoreError, event_cache::EventCacheError, oidc::OidcError, + send_queue::RoomSendQueueError, HttpError, IdParseError, + NotificationSettingsError as SdkNotificationSettingsError, StoreError, }; use matrix_sdk_ui::{encryption_sync_service, notification_client, sync_service, timeline}; use uniffi::UnexpectedUniFFICallbackError; @@ -91,6 +92,12 @@ impl From for ClientError { } } +impl From for ClientError { + fn from(e: timeline::UnsupportedEditItem) -> Self { + Self::new(e) + } +} + impl From for ClientError { fn from(e: notification_client::Error) -> Self { Self::new(e) @@ -121,6 +128,12 @@ impl From for ClientError { } } +impl From for ClientError { + fn from(e: RoomSendQueueError) -> Self { + Self::new(e) + } +} + #[derive(Debug, thiserror::Error, uniffi::Error)] #[uniffi(flat_error)] pub enum RoomError { diff --git a/bindings/matrix-sdk-ffi/src/timeline/mod.rs b/bindings/matrix-sdk-ffi/src/timeline/mod.rs index 12e445f690c..ad9170b9f97 100644 --- a/bindings/matrix-sdk-ffi/src/timeline/mod.rs +++ b/bindings/matrix-sdk-ffi/src/timeline/mod.rs @@ -485,13 +485,9 @@ impl Timeline { item: Arc, new_content: Arc, ) -> Result { - let edit_info = item.0.edit_info().map_err(|err| anyhow::anyhow!(err))?; + let edit_info = item.0.edit_info().map_err(ClientError::from)?; - Ok(self - .inner - .edit((*new_content).clone(), edit_info) - .await - .map_err(|err| anyhow::anyhow!(err))?) + self.inner.edit((*new_content).clone(), edit_info).await.map_err(ClientError::from) } /// Edit an event given its event id. Useful when we're not sure a remote @@ -502,17 +498,10 @@ impl Timeline { new_content: Arc, ) -> Result<(), ClientError> { let event_id = EventId::parse(event_id)?; - let edit_info = self - .inner - .edit_info_from_event_id(&event_id) - .await - .map_err(|err| anyhow::anyhow!(err))?; - - self.inner - .edit((*new_content).clone(), edit_info) - .await - .map_err(|err| anyhow::anyhow!(err))?; + let edit_info = + self.inner.edit_info_from_event_id(&event_id).await.map_err(ClientError::from)?; + self.inner.edit((*new_content).clone(), edit_info).await.map_err(ClientError::from)?; Ok(()) }