From 28b614d5db8ae6b2c7f41aadae1599b83abd1145 Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 6 Apr 2026 23:44:28 +0300 Subject: [PATCH] handle db errors properly --- src/main.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index ac5d8db..8c7ec71 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,12 +44,20 @@ async fn main() { let items = result.content.items; debug!("received {:?} items to handle...", items.len()); for item in items { - if database.get(&item.id).is_ok_and(|r| r.is_some()) { - debug!( - "item `{}` for channel `{c}` already processed; skip handle.", + match database.get(&item.id) { + Ok(id) => { + if id.is_some() { + debug!( + "item `{}` for channel `{c}` already processed; skip handle.", + item.id + ); + continue; + } + } + Err(e) => panic!( + "can't check item `{}` in DB for channel `{c}`: {e}", item.id - ); - continue; + ), } if item.is_live != channel.is_live { debug!( @@ -85,7 +93,7 @@ async fn main() { "exec `{cmd}` for channel `{c}` successful: `{:?}`", response ), - Err(e) => error!( + Err(e) => panic!( "can't persist processed item `{}` for channel `{c}` by `{cmd}`: `{e}`", item.id ),