Skip to content

Commit ef07d65

Browse files
davidmarkclementsmcollina
authored andcommitted
errors: change ERR_HTTP2_HEADER_SINGLE_VALUE to TypeError
changes the base instance for ERR_HTTP2_HEADER_SINGLE_VALUE from Error to TypeError as a more accurate representation of the error. Additionally corrects the grammar of the error message. PR-URL: #19805 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent add1c02 commit ef07d65

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

lib/internal/errors.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,8 @@ E('ERR_HTTP2_HEADERS_AFTER_RESPOND',
718718
'Cannot specify additional headers after response initiated', Error);
719719
E('ERR_HTTP2_HEADERS_SENT', 'Response has already been initiated.', Error);
720720

721-
// This should probably be a `TypeError`.
722721
E('ERR_HTTP2_HEADER_SINGLE_VALUE',
723-
'Header field "%s" must have only a single value', Error);
722+
'Header field "%s" must only have a single value', TypeError);
724723
E('ERR_HTTP2_INFO_STATUS_NOT_ALLOWED',
725724
'Informational status codes cannot be used', RangeError);
726725

test/parallel/test-http2-multi-content-length.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ server.listen(0, common.mustCall(() => {
3131
});
3232
}, {
3333
code: 'ERR_HTTP2_HEADER_SINGLE_VALUE',
34-
type: Error,
35-
message: 'Header field "content-length" must have only a single value'
34+
type: TypeError,
35+
message: 'Header field "content-length" must only have a single value'
3636
}
3737
);
3838

test/parallel/test-http2-single-headers.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ server.listen(0, common.mustCall(() => {
3131
() => client.request({ [i]: 'abc', [i.toUpperCase()]: 'xyz' }),
3232
{
3333
code: 'ERR_HTTP2_HEADER_SINGLE_VALUE',
34-
type: Error,
35-
message: `Header field "${i}" must have only a single value`
34+
type: TypeError,
35+
message: `Header field "${i}" must only have a single value`
3636
}
3737
);
3838

3939
common.expectsError(
4040
() => client.request({ [i]: ['abc', 'xyz'] }),
4141
{
4242
code: 'ERR_HTTP2_HEADER_SINGLE_VALUE',
43-
type: Error,
44-
message: `Header field "${i}" must have only a single value`
43+
type: TypeError,
44+
message: `Header field "${i}" must only have a single value`
4545
}
4646
);
4747
});

test/parallel/test-http2-util-headers-list.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ const {
177177

178178
common.expectsError({
179179
code: 'ERR_HTTP2_HEADER_SINGLE_VALUE',
180-
type: Error,
181-
message: 'Header field ":status" must have only a single value'
180+
type: TypeError,
181+
message: 'Header field ":status" must only have a single value'
182182
})(mapToHeaders(headers));
183183
}
184184

@@ -223,7 +223,7 @@ const {
223223
HTTP2_HEADER_USER_AGENT,
224224
HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS
225225
].forEach((name) => {
226-
const msg = `Header field "${name}" must have only a single value`;
226+
const msg = `Header field "${name}" must only have a single value`;
227227
common.expectsError({
228228
code: 'ERR_HTTP2_HEADER_SINGLE_VALUE',
229229
message: msg

0 commit comments

Comments
 (0)