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();
|
let rooms = rooms_clone.read().await.clone();
|
||||||
|
|
||||||
for room in rooms {
|
for room in rooms {
|
||||||
room.send(
|
let send_response = room
|
||||||
matrix_sdk::ruma::events::room::message::RoomMessageEventContent::new(msg.clone()),
|
.send(
|
||||||
)
|
matrix_sdk::ruma::events::room::message::RoomMessageEventContent::new(
|
||||||
.await
|
msg.clone(),
|
||||||
.context("Failed to send message to room.")?;
|
),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
if send_response.is_err() {
|
||||||
|
log::error!(
|
||||||
|
"Error sending to room {}. Error \n: {:?}",
|
||||||
|
room.room_id(),
|
||||||
|
send_response
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -113,6 +122,7 @@ impl MatrixListener {
|
||||||
.await
|
.await
|
||||||
.context("Failed on initial sync.")?
|
.context("Failed on initial sync.")?
|
||||||
.next_batch;
|
.next_batch;
|
||||||
|
|
||||||
self.client.add_event_handler(on_room_message);
|
self.client.add_event_handler(on_room_message);
|
||||||
// Spawn a task for the rest of the syncs.
|
// Spawn a task for the rest of the syncs.
|
||||||
let spawn_client = self.client.clone();
|
let spawn_client = self.client.clone();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue