handle db errors properly

This commit is contained in:
yggverse 2026-04-06 23:44:28 +03:00
parent b676060798
commit 28b614d5db

View file

@ -44,12 +44,20 @@ async fn main() {
let items = result.content.items; let items = result.content.items;
debug!("received {:?} items to handle...", items.len()); debug!("received {:?} items to handle...", items.len());
for item in items { for item in items {
if database.get(&item.id).is_ok_and(|r| r.is_some()) { match database.get(&item.id) {
debug!( Ok(id) => {
"item `{}` for channel `{c}` already processed; skip handle.", 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 item.id
); ),
continue;
} }
if item.is_live != channel.is_live { if item.is_live != channel.is_live {
debug!( debug!(
@ -85,7 +93,7 @@ async fn main() {
"exec `{cmd}` for channel `{c}` successful: `{:?}`", "exec `{cmd}` for channel `{c}` successful: `{:?}`",
response response
), ),
Err(e) => error!( Err(e) => panic!(
"can't persist processed item `{}` for channel `{c}` by `{cmd}`: `{e}`", "can't persist processed item `{}` for channel `{c}` by `{cmd}`: `{e}`",
item.id item.id
), ),