Gracefully handle send errors.
This commit is contained in:
parent
39c532f09b
commit
1a9331917a
|
|
@ -71,11 +71,20 @@ impl MatrixListener {
|
|||
let rooms = rooms_clone.read().await.clone();
|
||||
|
||||
for room in rooms {
|
||||
room.send(
|
||||
matrix_sdk::ruma::events::room::message::RoomMessageEventContent::new(msg.clone()),
|
||||
)
|
||||
.await
|
||||
.context("Failed to send message to room.")?;
|
||||
let send_response = room
|
||||
.send(
|
||||
matrix_sdk::ruma::events::room::message::RoomMessageEventContent::new(
|
||||
msg.clone(),
|
||||
),
|
||||
)
|
||||
.await;
|
||||
if send_response.is_err() {
|
||||
log::error!(
|
||||
"Error sending to room {}. Error \n: {:?}",
|
||||
room.room_id(),
|
||||
send_response
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
@ -113,6 +122,7 @@ impl MatrixListener {
|
|||
.await
|
||||
.context("Failed on initial sync.")?
|
||||
.next_batch;
|
||||
|
||||
self.client.add_event_handler(on_room_message);
|
||||
// Spawn a task for the rest of the syncs.
|
||||
let spawn_client = self.client.clone();
|
||||
|
|
|
|||
Loading…
Reference in New Issue