diff --git a/js/fetch_test.ts b/js/fetch_test.ts index 74a3836496..cd3e6ebf08 100644 --- a/js/fetch_test.ts +++ b/js/fetch_test.ts @@ -47,6 +47,17 @@ testPerm({ net: true }, async function responseClone() { } }); +testPerm({ net: true }, async function fetchEmptyInvalid() { + let err; + try { + await fetch(""); + } catch (err_) { + err = err_; + } + assertEqual(err.kind, deno.ErrorKind.InvalidUri); + assertEqual(err.name, "InvalidUri"); +}); + // TODO(ry) The following tests work but are flaky. There's a race condition // somewhere. Here is what one of these flaky failures looks like: // diff --git a/src/msg.fbs b/src/msg.fbs index 9cdb628a15..b576d0f23d 100644 --- a/src/msg.fbs +++ b/src/msg.fbs @@ -106,6 +106,9 @@ enum ErrorKind: byte { HttpParse, HttpOther, TooLarge, + + // custom errors + InvalidUri, } table Cwd {} diff --git a/src/msg_util.rs b/src/msg_util.rs index a78074ab16..ae5e2dc51e 100644 --- a/src/msg_util.rs +++ b/src/msg_util.rs @@ -1,5 +1,7 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. // Helpers for serialization. +use errors; +use errors::DenoResult; use flatbuffers; use http::header::HeaderName; use http::uri::Uri; @@ -94,13 +96,14 @@ pub fn serialize_http_response<'bldr>( pub fn deserialize_request( header_msg: msg::HttpHeader, body: Body, -) -> Request
{ +) -> DenoResult