From dfd4b77d6e99856e4c6b45edc1626e99867cbe14 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Sat, 27 Mar 2021 10:00:04 -0600 Subject: actually handle errors --- src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 21b4d82..28de762 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,7 +25,7 @@ struct Args { } #[tokio::main] -async fn main() -> Result<(), Error> { +async fn main() -> Result<(), Vec> { let (args, urls) = { let mut args: Args = Args::from_args(); let mut urls = mem::take(&mut args.urls); @@ -48,7 +48,13 @@ async fn main() -> Result<(), Error> { .into_iter() .map(|url| download(url, &args)); let downloads = futures::future::join_all(download_handles); - let _downloads = downloads.await; - - Ok(()) + let download_errors = downloads.await + .into_iter() + .filter_map(|x| x.err()) + .collect::>(); + if download_errors.len() > 0 { + Err(download_errors) + } else { + Ok(()) + } } -- cgit v1.2.3