Skip to content

Commit e9b7727

Browse files
wip, better errors
1 parent c48bff1 commit e9b7727

File tree

5 files changed

+51
-51
lines changed

5 files changed

+51
-51
lines changed

src/features/js_fetch/spec.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ pub trait Request {
382382
pub async fn do_fetch(url: Option<String>, fetch_init: FetchInit) -> Result<Response, JsError> {
383383
let client = reqwest::ClientBuilder::new()
384384
.build()
385-
.map_err(|e| JsError::new_string(format!("{e}")))?;
385+
.map_err(|e| JsError::new_string(format!("{e:?}")))?;
386386
do_fetch2(&client, url, fetch_init).await
387387
}
388388

@@ -393,9 +393,9 @@ pub async fn do_fetch2(
393393
) -> Result<Response, JsError> {
394394
if let Some(url) = url {
395395
let method = reqwest::Method::from_str(fetch_init.method.as_str())
396-
.map_err(|e| JsError::new_string(format!("{e}")))?;
396+
.map_err(|e| JsError::new_string(format!("{e:?}")))?;
397397

398-
let mut request = client.request(method, url);
398+
let mut request = client.request(method, &url);
399399

400400
if let Some(body) = fetch_init.body {
401401
if let Some(text) = body.text.as_ref() {
@@ -415,7 +415,7 @@ pub async fn do_fetch2(
415415

416416
let reqwest_resp = response_fut
417417
.await
418-
.map_err(|e| JsError::new_string(format!("{e}")))?;
418+
.map_err(|e| JsError::new_string(format!("reqwest error {e:?}")))?;
419419

420420
let mut headers = Headers::new();
421421
for hv in reqwest_resp.headers() {
@@ -424,7 +424,7 @@ pub async fn do_fetch2(
424424
vec![hv
425425
.1
426426
.to_str()
427-
.map_err(|e| JsError::new_string(format!("{}", e)))?
427+
.map_err(|e| JsError::new_string(format!("{e:?}")))?
428428
.to_string()],
429429
);
430430
}
@@ -436,7 +436,7 @@ pub async fn do_fetch2(
436436
if let Some(ct) = reqwest_resp.headers().get("content-type") {
437437
let ct_str = ct
438438
.to_str()
439-
.map_err(|e| JsError::new_string(format!("{}", e)))?;
439+
.map_err(|e| JsError::new_string(format!("{e:?}")))?;
440440
if ct_str.eq("text/plain")
441441
|| ct_str.eq("text/html")
442442
|| ct_str.eq("application/json")
@@ -453,15 +453,15 @@ pub async fn do_fetch2(
453453
reqwest_resp
454454
.text()
455455
.await
456-
.map_err(|e| JsError::new_string(format!("{e}")))?,
456+
.map_err(|e| JsError::new_string(format!("{e:?}")))?,
457457
),
458458
bytes: None,
459459
}
460460
} else {
461461
let bytes: Vec<u8> = reqwest_resp
462462
.bytes()
463463
.await
464-
.map_err(|e| JsError::new_string(format!("{}", e)))?
464+
.map_err(|e| JsError::new_string(format!("{e:?}")))?
465465
.to_vec();
466466

467467
Body {

0 commit comments

Comments
 (0)