From d0eba8fa34d2f3fec123424e5421422babd9e331 Mon Sep 17 00:00:00 2001 From: 4o1x5 <4o1x5@4o1x5.dev> Date: Fri, 25 Oct 2024 23:38:19 +0200 Subject: [PATCH] lib.rs handled unwraps for errored deliveries --- src/lib.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f6f37e5..18e7f14 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -241,10 +241,15 @@ impl BunBunWorker { consumer .for_each_concurrent(None, move |delivery| { let handler = Arc::clone(&handler); - // TODO handle unwrap of delivery - let delivery = delivery.unwrap(); async move { - handler(delivery).await; + match delivery { + Err(error) => { + tracing::warn!("Received bad msg: {}", error); + } + Ok(delivery) => { + handler(delivery).await; + } + } } }) .await; @@ -263,10 +268,15 @@ impl BunBunWorker { consumer .for_each_concurrent(None, move |delivery| { let handler = Arc::clone(&handler); - // TODO handle unwrap of delivery - let delivery = delivery.unwrap(); async move { - handler(delivery).await; + match delivery { + Err(error) => { + tracing::warn!("Received bad msg: {}", error); + } + Ok(delivery) => { + handler(delivery).await; + } + } } }) .await;