Skip to content

Commit 6bd01cb

Browse files
committed
fix: don't hard-error on unreadable messages
For reasons I don't understand, Galileo can fail to create a MessageInfo object from a Message. If that conversion fails, we can't proceed. The unwrap was causing a fatal error; instead, let's just log it and keep going. Closes #101.
1 parent d49167b commit 6bd01cb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/handler.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,15 @@ impl EventHandler for Handler {
261261
/// window, then Galileo will respond instructing the user to wait longer.
262262
async fn message(&self, ctx: Context, message: Message) {
263263
// Check whether we should proceed.
264-
let message_info = MessageInfo::new(&message, &ctx).unwrap();
264+
let message_info = match MessageInfo::new(&message, &ctx) {
265+
Ok(m) => m,
266+
Err(e) => {
267+
// We can't return an error, but we also can't proceed, so log the error
268+
// and bare-return to bail out.
269+
tracing::error!(%e, "failed to get message info for message");
270+
return;
271+
}
272+
};
265273
if !self.should_send(&ctx, &message_info).await {
266274
return;
267275
}

0 commit comments

Comments
 (0)