From b3dc24c3b80696f126fa8ed7b174ff47c76c9e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Wed, 19 Jan 2022 23:27:35 +0100 Subject: [PATCH] properly log torrent errors --- src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index ef84095..195e929 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,11 +37,17 @@ fn main() { ); debug!("Torrent files: {}", torrent_files.join(", ")); - let torrents = torrent_files + let torrents: Vec<(&str, Torrent)> = torrent_files .into_iter() - .map(|f| Torrent::read_from_file(f).map(|t| (f, t))) - .collect::, _>>() - .unwrap(); + .map(|path| (path, Torrent::read_from_file(path))) + .filter_map(|(path, torrent)| match torrent { + Ok(torrent) => Some((path, torrent)), + Err(err) => { + error!("Error loading \"{path}\"! {err}"); + None + } + }) + .collect(); for dir_entry in WalkDir::new(search_path).into_iter() { if let Ok(dir_entry) = dir_entry {