summaryrefslogtreecommitdiff
path: root/op_crates/fetch/lib.rs
diff options
context:
space:
mode:
authorYosi Pramajaya <yosi.pramajaya@gmail.com>2020-12-26 20:06:00 +0700
committerGitHub <noreply@github.com>2020-12-26 08:06:00 -0500
commitc1fdb30394ab336ec2e004d563be40180e218b0d (patch)
tree13352d292e08114300463ca02eb7b70b4efb88f5 /op_crates/fetch/lib.rs
parentbfe1b053815f68b121691e9690b8353178d86128 (diff)
fix: fetch bad URL will not panic (#8884)
Diffstat (limited to 'op_crates/fetch/lib.rs')
-rw-r--r--op_crates/fetch/lib.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/op_crates/fetch/lib.rs b/op_crates/fetch/lib.rs
index 4bc37b998..91e44f75c 100644
--- a/op_crates/fetch/lib.rs
+++ b/op_crates/fetch/lib.rs
@@ -8,7 +8,6 @@ use deno_core::error::AnyError;
use deno_core::serde_json;
use deno_core::serde_json::json;
use deno_core::serde_json::Value;
-use deno_core::url;
use deno_core::url::Url;
use deno_core::AsyncRefCell;
use deno_core::BufVec;
@@ -126,7 +125,7 @@ where
None => Method::GET,
};
- let url_ = url::Url::parse(&url)?;
+ let url_ = Url::parse(&url)?;
// Check scheme before asking for net permission
let scheme = url_.scheme();
@@ -155,7 +154,10 @@ where
}
//debug!("Before fetch {}", url);
- let res = request.send().await?;
+ let res = match request.send().await {
+ Ok(res) => res,
+ Err(e) => return Err(type_error(e.to_string())),
+ };
//debug!("Fetch response {}", url);
let status = res.status();