aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-03-27 10:00:04 -0600
committerMelody Horn <melody@boringcactus.com>2021-03-27 10:00:04 -0600
commitdfd4b77d6e99856e4c6b45edc1626e99867cbe14 (patch)
treeb855415d83c51ac8e34b1fc59d696298c8735d60 /src
parent6db93c26dd904dd83744b2c1a2ec81a95237151a (diff)
downloadwebget-dfd4b77d6e99856e4c6b45edc1626e99867cbe14.tar.gz
webget-dfd4b77d6e99856e4c6b45edc1626e99867cbe14.zip
actually handle errors
Diffstat (limited to 'src')
-rw-r--r--src/main.rs14
1 files 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<Error>> {
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::<Vec<Error>>();
+ if download_errors.len() > 0 {
+ Err(download_errors)
+ } else {
+ Ok(())
+ }
}