chore: Make error message more helpful

This commit is contained in:
EmperorBale 2021-03-27 12:43:43 -07:00 committed by kmeisthax
parent 51e2ebf492
commit e36ad2874b
2 changed files with 12 additions and 2 deletions

View File

@ -149,7 +149,12 @@ impl NavigatorBackend for ExternalNavigatorBackend {
.map_err(|e| Error::FetchError(e.to_string()))?; .map_err(|e| Error::FetchError(e.to_string()))?;
if !response.status().is_success() { 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![]; let mut buffer = vec![];

View File

@ -176,9 +176,14 @@ impl NavigatorBackend for WebNavigatorBackend {
} }
let resp: Response = fetchval.unwrap().dyn_into().unwrap(); let resp: Response = fetchval.unwrap().dyn_into().unwrap();
if !resp.ok() { 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()) let data: ArrayBuffer = JsFuture::from(resp.array_buffer().unwrap())
.await .await
.unwrap() .unwrap()