diff --git a/bindings/matrix-sdk-ffi/src/error.rs b/bindings/matrix-sdk-ffi/src/error.rs index c880a961aad..39f2ebf3b88 100644 --- a/bindings/matrix-sdk-ffi/src/error.rs +++ b/bindings/matrix-sdk-ffi/src/error.rs @@ -135,19 +135,18 @@ pub enum MediaInfoError { } #[derive(Debug, thiserror::Error, uniffi::Error)] -#[uniffi(flat_error)] pub enum NotificationSettingsError { #[error("client error: {msg}")] Generic { msg: String }, /// Invalid parameter. - #[error("Invalid parameter `{0}`")] - InvalidParameter(String), + #[error("Invalid parameter: {msg}")] + InvalidParameter { msg: String }, /// Invalid room id. - #[error("Invalid room ID `{0}`")] - InvalidRoomId(String), + #[error("Invalid room ID {room_id}")] + InvalidRoomId { room_id: String }, /// Rule not found - #[error("Rule not found")] - RuleNotFound(String), + #[error("Rule not found: {rule_id}")] + RuleNotFound { rule_id: String }, /// Unable to add push rule. #[error("Unable to add push rule")] UnableToAddPushRule, @@ -165,13 +164,11 @@ pub enum NotificationSettingsError { impl From for NotificationSettingsError { fn from(value: SdkNotificationSettingsError) -> Self { match value { - SdkNotificationSettingsError::RuleNotFound(rule_id) => Self::RuleNotFound(rule_id), + SdkNotificationSettingsError::RuleNotFound(rule_id) => Self::RuleNotFound { rule_id }, SdkNotificationSettingsError::UnableToAddPushRule => Self::UnableToAddPushRule, SdkNotificationSettingsError::UnableToRemovePushRule => Self::UnableToRemovePushRule, SdkNotificationSettingsError::UnableToSavePushRules => Self::UnableToSavePushRules, - SdkNotificationSettingsError::InvalidParameter(parameter) => { - Self::InvalidParameter(parameter) - } + SdkNotificationSettingsError::InvalidParameter(msg) => Self::InvalidParameter { msg }, SdkNotificationSettingsError::UnableToUpdatePushRule => Self::UnableToUpdatePushRule, } } diff --git a/bindings/matrix-sdk-ffi/src/notification_settings.rs b/bindings/matrix-sdk-ffi/src/notification_settings.rs index 159aed25546..239031aaa06 100644 --- a/bindings/matrix-sdk-ffi/src/notification_settings.rs +++ b/bindings/matrix-sdk-ffi/src/notification_settings.rs @@ -145,7 +145,7 @@ impl NotificationSettings { ) -> Result { let notification_settings = self.sdk_notification_settings.read().await; let parsed_room_id = RoomId::parse(&room_id) - .map_err(|_e| NotificationSettingsError::InvalidRoomId(room_id))?; + .map_err(|_e| NotificationSettingsError::InvalidRoomId { room_id })?; // Get the current user defined mode for this room if let Some(mode) = notification_settings.get_user_defined_room_notification_mode(&parsed_room_id).await @@ -180,7 +180,7 @@ impl NotificationSettings { ) -> Result<(), NotificationSettingsError> { let notification_settings = self.sdk_notification_settings.read().await; let parsed_room_id = RoomId::parse(&room_id) - .map_err(|_e| NotificationSettingsError::InvalidRoomId(room_id))?; + .map_err(|_e| NotificationSettingsError::InvalidRoomId { room_id })?; notification_settings.set_room_notification_mode(&parsed_room_id, mode.into()).await?; Ok(()) } @@ -200,7 +200,7 @@ impl NotificationSettings { ) -> Result, NotificationSettingsError> { let notification_settings = self.sdk_notification_settings.read().await; let parsed_room_id = RoomId::parse(&room_id) - .map_err(|_e| NotificationSettingsError::InvalidRoomId(room_id))?; + .map_err(|_e| NotificationSettingsError::InvalidRoomId { room_id })?; // Get the current user defined mode for this room if let Some(mode) = notification_settings.get_user_defined_room_notification_mode(&parsed_room_id).await @@ -293,7 +293,7 @@ impl NotificationSettings { ) -> Result<(), NotificationSettingsError> { let notification_settings = self.sdk_notification_settings.read().await; let parsed_room_id = RoomId::parse(&room_id) - .map_err(|_e| NotificationSettingsError::InvalidRoomId(room_id))?; + .map_err(|_e| NotificationSettingsError::InvalidRoomId { room_id })?; notification_settings.delete_user_defined_room_rules(&parsed_room_id).await?; Ok(()) } @@ -459,7 +459,7 @@ impl NotificationSettings { ) -> Result<(), NotificationSettingsError> { let notification_settings = self.sdk_notification_settings.read().await; let parsed_room_id = RoomId::parse(&room_id) - .map_err(|_e| NotificationSettingsError::InvalidRoomId(room_id))?; + .map_err(|_e| NotificationSettingsError::InvalidRoomId { room_id })?; notification_settings .unmute_room(&parsed_room_id, is_encrypted.into(), is_one_to_one.into()) .await?;