diff --git a/src/main.rs b/src/main.rs index 6936c52..80fda23 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,7 +39,7 @@ use crate::{ }; use std::{ sync::Arc, cmp::max }; -use tracing::{ info, debug }; +use tracing::{ info, debug, error }; use chrono::DateTime; #[tokio::main] @@ -63,8 +63,24 @@ async fn main() -> anyhow::Result<()> { tokio::spawn(async move { loop { - let feed = fetch_and_parse_feed(&feed_config.url).await - .expect("Failed to parse feed"); + let feed: Option<_> = match fetch_and_parse_feed(&feed_config.url).await { + Ok(f) => Some(f), + Err(e) => { + error!("Failed to parse feed {}: {:?}", + feed_config.url, + e + ); + None + } + }; + + let feed = if feed.is_none() { + info!("Sleeping for {} seconds before refreshing this feed", feed_config.delay); + sleep(Duration::from_secs(feed_config.delay)).await; + continue; + } else { + feed.unwrap() + }; let rooms = feed_config.rooms.clone();