main: Improve feed parse error handling
This commit is contained in:
parent
b93f921bcb
commit
d0ac11ea89
22
src/main.rs
22
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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user