From e36ad2874b5492e7790bfb953d7244b05a2268f2 Mon Sep 17 00:00:00 2001 From: EmperorBale Date: Sat, 27 Mar 2021 12:43:43 -0700 Subject: [PATCH] chore: Make error message more helpful --- desktop/src/navigator.rs | 7 ++++++- web/src/navigator.rs | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/desktop/src/navigator.rs b/desktop/src/navigator.rs index 883d2a0fb..3c2798433 100644 --- a/desktop/src/navigator.rs +++ b/desktop/src/navigator.rs @@ -149,7 +149,12 @@ impl NavigatorBackend for ExternalNavigatorBackend { .map_err(|e| Error::FetchError(e.to_string()))?; if !response.status().is_success() { - return Err(Error::FetchError("HTTP status is not ok".to_string())); + return Err(Error::FetchError(format!( + "HTTP status is not ok, got {}", + response.status().canonical_reason().unwrap_or( + format!("unknown status {}", response.status().as_u16()).as_str() + ) + ))); } let mut buffer = vec![]; diff --git a/web/src/navigator.rs b/web/src/navigator.rs index 253798c90..170c56521 100644 --- a/web/src/navigator.rs +++ b/web/src/navigator.rs @@ -176,9 +176,14 @@ impl NavigatorBackend for WebNavigatorBackend { } let resp: Response = fetchval.unwrap().dyn_into().unwrap(); + if !resp.ok() { - return Err(Error::FetchError("HTTP status is not ok".to_string())); + return Err(Error::FetchError(format!( + "HTTP status is not ok, got {}", + resp.status_text() + ))); } + let data: ArrayBuffer = JsFuture::from(resp.array_buffer().unwrap()) .await .unwrap()