aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/download.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/download.rs b/src/download.rs
index 7cf9694..80a159b 100644
--- a/src/download.rs
+++ b/src/download.rs
@@ -1,6 +1,6 @@
use std::path::{Path, PathBuf};
-use anyhow::{Error, Context};
+use anyhow::{bail, Error, Context};
use fehler::throws;
use hyper::Uri;
use hyper::body::HttpBody;
@@ -36,7 +36,7 @@ pub(crate) async fn download(url: Uri, args: &Args) {
response = client.get(location).await?;
}
if !response.status().is_success() {
- panic!("non-success response code {} in URL {}", response.status(), url);
+ bail!("non-success response code {} in URL {}", response.status(), url);
}
let output_file_path = if let Some(path) = output_file_path {
@@ -51,7 +51,7 @@ pub(crate) async fn download(url: Uri, args: &Args) {
PathBuf::from(format!("index{}", extension))
};
- let mut output_file = fs::File::create(output_file_path).await.expect("couldn't open output file!");
+ let mut output_file = fs::File::create(output_file_path).await?;
while let Some(data) = response.body_mut().data().await {
output_file.write_all(&data?).await?;