From 9e6be24e5be20855038852b310f05b045bb3b085 Mon Sep 17 00:00:00 2001 From: Luc Georges Date: Tue, 23 Jul 2024 11:06:38 +0200 Subject: [PATCH] refactor: display a better error msg on status error --- src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 6182384..535c2e4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -189,7 +189,9 @@ async fn download_async( .header(RANGE, "bytes=0-0") .send() .await - .map_err(|err| PyException::new_err(format!("Error while downloading: {err:?}")))?; + .map_err(|err| PyException::new_err(format!("Error while downloading: {err:?}")))? + .error_for_status() + .map_err(|err| PyException::new_err(err.to_string()))?; // Only call the final redirect URL to avoid overloading the Hub with requests and also // altering the download count