From 131e7dd919d99e3d04aec935b6011f9efa7ed065 Mon Sep 17 00:00:00 2001 From: Michael Schubert Date: Fri, 24 Oct 2025 20:42:55 +0200 Subject: [PATCH 1/2] Print details with "failed to save item" error message Print the SQLite error message as well as the guid and link to actually allow the user to understand the source of error. --- src/feed.rs | 5 +++-- src/main.rs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/feed.rs b/src/feed.rs index 46b4309..4c7b43d 100644 --- a/src/feed.rs +++ b/src/feed.rs @@ -2,7 +2,7 @@ use core::fmt::Debug; use std::fmt; use std::sync::Arc; -use anyhow::{anyhow, Result}; +use anyhow::{anyhow, Context, Result}; use async_trait::async_trait; use sqlx::{Pool, Sqlite}; use tokio::sync::Mutex; @@ -275,7 +275,8 @@ impl FeedItem { self.published_at, ) .execute(&self.db) - .await?; + .await + .with_context(|| format!("guid: '{}' link: '{}'", self.guid, self.link))?; Ok(()) } diff --git a/src/main.rs b/src/main.rs index c474c1f..e739bcd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -140,7 +140,7 @@ async fn main() -> Result<()> { match item.save().await { Ok(_) => (), Err(e) => { - return Err(anyhow!("failed to save item '{}': {}", item.guid, e)); + return Err(anyhow!("failed to save item: {:?}", e)); } }; @@ -228,7 +228,7 @@ async fn main() -> Result<()> { match res { Ok(Ok(_)) => (), Ok(Err(e)) => { - println!("failed to save item: {}", e); + println!("{}", e); // This could happen if the feed item has a duplicate guid; // we don't want to exit in this case and ignore this for now } From 4663d842959607521e5bcb66403351a0d7a5458e Mon Sep 17 00:00:00 2001 From: Michael Schubert Date: Thu, 30 Oct 2025 12:32:07 +0100 Subject: [PATCH 2/2] Print URL for `rss::Channel::read_from()` errors --- src/feed.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/feed.rs b/src/feed.rs index 4c7b43d..0c940fa 100644 --- a/src/feed.rs +++ b/src/feed.rs @@ -135,7 +135,8 @@ impl Feed for RSSFeed { .timeout(std::time::Duration::from_secs(15)) .build()?; let response = client.get(&self.url).send().await?.text().await?; - let rssfeed = rss::Channel::read_from(response.as_bytes())?; + let rssfeed = rss::Channel::read_from(response.as_bytes()) + .with_context(|| format!("failed to parse RSS feed from '{}'", self.url))?; let feed: Arc>> = Arc::new(Mutex::new(Box::new(self.clone()) as Box)); @@ -211,7 +212,7 @@ impl Feed for AtomFeed { Ok(feed) => feed, Err(e) => { return Err(anyhow!( - "failed to parse atom feed from '{}': {}", + "failed to parse Atom feed from '{}': {}", self.url, e ));