mirror of
https://github.com/denoland/deno.git
synced 2025-09-23 02:42:34 +00:00
refactor(ext): align error messages (#25496)
Aligns the error messages in the ext/http and a few messages in the ext/fetch folder to be in-line with the Deno style guide. This change-set also removes some unnecessary checks in the 00_serve.ts. These options were recently removed, so it doesn't make sense to check for them anymore. https://github.com/denoland/deno/issues/25269
This commit is contained in:
parent
fd23e8ec4f
commit
282c4c262d
4 changed files with 31 additions and 29 deletions
|
@ -122,7 +122,7 @@ function newInnerRequest(method, url, headerList, body, maybeBlob) {
|
|||
try {
|
||||
this.headerListInner = headerList();
|
||||
} catch {
|
||||
throw new TypeError("cannot read headers: request closed");
|
||||
throw new TypeError("Cannot read headers: request closed");
|
||||
}
|
||||
}
|
||||
return this.headerListInner;
|
||||
|
@ -153,7 +153,7 @@ function newInnerRequest(method, url, headerList, body, maybeBlob) {
|
|||
try {
|
||||
this.urlListProcessed[currentIndex] = this.urlList[currentIndex]();
|
||||
} catch {
|
||||
throw new TypeError("cannot read url: request closed");
|
||||
throw new TypeError("Cannot read url: request closed");
|
||||
}
|
||||
}
|
||||
return this.urlListProcessed[currentIndex];
|
||||
|
@ -193,7 +193,7 @@ function cloneInnerRequest(request, skipBody = false) {
|
|||
try {
|
||||
this.urlListProcessed[0] = this.urlList[0]();
|
||||
} catch {
|
||||
throw new TypeError("cannot read url: request closed");
|
||||
throw new TypeError("Cannot read url: request closed");
|
||||
}
|
||||
}
|
||||
return this.urlListProcessed[0];
|
||||
|
@ -204,7 +204,7 @@ function cloneInnerRequest(request, skipBody = false) {
|
|||
try {
|
||||
this.urlListProcessed[currentIndex] = this.urlList[currentIndex]();
|
||||
} catch {
|
||||
throw new TypeError("cannot read url: request closed");
|
||||
throw new TypeError("Cannot read url: request closed");
|
||||
}
|
||||
}
|
||||
return this.urlListProcessed[currentIndex];
|
||||
|
@ -236,13 +236,13 @@ const KNOWN_METHODS = {
|
|||
*/
|
||||
function validateAndNormalizeMethod(m) {
|
||||
if (RegExpPrototypeExec(HTTP_TOKEN_CODE_POINT_RE, m) === null) {
|
||||
throw new TypeError("Method is not valid.");
|
||||
throw new TypeError("Method is not valid");
|
||||
}
|
||||
const upperCase = byteUpperCase(m);
|
||||
if (
|
||||
upperCase === "CONNECT" || upperCase === "TRACE" || upperCase === "TRACK"
|
||||
) {
|
||||
throw new TypeError("Method is forbidden.");
|
||||
throw new TypeError("Method is forbidden");
|
||||
}
|
||||
return upperCase;
|
||||
}
|
||||
|
@ -418,7 +418,7 @@ class Request {
|
|||
((init.body !== undefined && init.body !== null) ||
|
||||
inputBody !== null)
|
||||
) {
|
||||
throw new TypeError("Request with GET/HEAD method cannot have body.");
|
||||
throw new TypeError("Request with GET/HEAD method cannot have body");
|
||||
}
|
||||
|
||||
// 36.
|
||||
|
@ -442,7 +442,7 @@ class Request {
|
|||
// 41.
|
||||
if (initBody === null && inputBody !== null) {
|
||||
if (input[_body] && input[_body].unusable()) {
|
||||
throw new TypeError("Input request's body is unusable.");
|
||||
throw new TypeError("Input request's body is unusable");
|
||||
}
|
||||
finalBody = inputBody.createProxy();
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ class Request {
|
|||
const prefix = "Failed to execute 'Request.clone'";
|
||||
webidl.assertBranded(this, RequestPrototype);
|
||||
if (this[_body] && this[_body].unusable()) {
|
||||
throw new TypeError("Body is unusable.");
|
||||
throw new TypeError("Body is unusable");
|
||||
}
|
||||
const clonedReq = cloneInnerRequest(this[_request]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue