summaryrefslogtreecommitdiff
path: root/ext/fetch/23_response.js
diff options
context:
space:
mode:
authorIan Bull <irbull@gmail.com>2024-09-04 00:05:29 -0700
committerGitHub <noreply@github.com>2024-09-04 09:05:29 +0200
commitce6b6751028bfe08b49628a30e660ff479eded02 (patch)
treeb0262dcbfa8e40aca090486eab959f04ae725ffc /ext/fetch/23_response.js
parent7079acd74d583a14f3c09e16f196a6851381439b (diff)
refactor(ext/fetch): align error messages (#25374)
Aligns the error messages in the ext/fetch folder to be in-line with the Deno style guide. https://github.com/denoland/deno/issues/25269
Diffstat (limited to 'ext/fetch/23_response.js')
-rw-r--r--ext/fetch/23_response.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/fetch/23_response.js b/ext/fetch/23_response.js
index 94fc69a98..7dad8c047 100644
--- a/ext/fetch/23_response.js
+++ b/ext/fetch/23_response.js
@@ -172,7 +172,7 @@ function initializeAResponse(response, init, bodyWithType) {
// 1.
if ((init.status < 200 || init.status > 599) && init.status != 101) {
throw new RangeError(
- `The status provided (${init.status}) is not equal to 101 and outside the range [200, 599].`,
+ `The status provided (${init.status}) is not equal to 101 and outside the range [200, 599]`,
);
}
@@ -181,7 +181,9 @@ function initializeAResponse(response, init, bodyWithType) {
init.statusText &&
RegExpPrototypeExec(REASON_PHRASE_RE, init.statusText) === null
) {
- throw new TypeError("Status text is not valid.");
+ throw new TypeError(
+ `Invalid status text: "${init.statusText}"`,
+ );
}
// 3.
@@ -263,7 +265,7 @@ class Response {
const baseURL = getLocationHref();
const parsedURL = new URL(url, baseURL);
if (!redirectStatus(status)) {
- throw new RangeError("Invalid redirect status code.");
+ throw new RangeError(`Invalid redirect status code: ${status}`);
}
const inner = newInnerResponse(status);
inner.type = "default";
@@ -395,7 +397,7 @@ class Response {
clone() {
webidl.assertBranded(this, ResponsePrototype);
if (this[_body] && this[_body].unusable()) {
- throw new TypeError("Body is unusable.");
+ throw new TypeError("Body is unusable");
}
const second = webidl.createBranded(Response);
const newRes = cloneInnerResponse(this[_response]);