chore: Make error message more helpful
This commit is contained in:
parent
51e2ebf492
commit
e36ad2874b
|
@ -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![];
|
||||||
|
|
|
@ -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()
|
||||||
|
|
Loading…
Reference in New Issue