From 3ef3351e6c9d74aeafe8d185f27ce078f166f363 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Sat, 27 Mar 2021 10:12:15 -0600 Subject: print response on failure status code --- src/download.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/download.rs b/src/download.rs index 82bb302..fa99ea5 100644 --- a/src/download.rs +++ b/src/download.rs @@ -36,7 +36,10 @@ pub(crate) async fn download(url: Uri, args: &Args) -> Result<(), Error> { response = client.get(location).await?; } if !response.status().is_success() { - bail!("non-success response code {} in URL {}", response.status(), url); + let status = response.status(); + let body = hyper::body::to_bytes(response.into_body()).await?; + let body = String::from_utf8_lossy(&body); + bail!("non-success response code {} in URL {}:\n{}\n", status, url, body); } let output_file_path = if let Some(path) = output_file_path { -- cgit v1.2.3