Skip to content

Commit

Permalink
errors: change ERR_HTTP2_HEADER_SINGLE_VALUE to TypeError
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
davidmarkclements authored and mcollina committed Apr 9, 2018
1 parent add1c02 commit ef07d65
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,8 @@ E('ERR_HTTP2_HEADERS_AFTER_RESPOND',
'Cannot specify additional headers after response initiated', Error);
E('ERR_HTTP2_HEADERS_SENT', 'Response has already been initiated.', Error);

// This should probably be a `TypeError`.
E('ERR_HTTP2_HEADER_SINGLE_VALUE',
'Header field "%s" must have only a single value', Error);
'Header field "%s" must only have a single value', TypeError);
E('ERR_HTTP2_INFO_STATUS_NOT_ALLOWED',
'Informational status codes cannot be used', RangeError);

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-http2-multi-content-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ server.listen(0, common.mustCall(() => {
});
}, {
code: 'ERR_HTTP2_HEADER_SINGLE_VALUE',
type: Error,
message: 'Header field "content-length" must have only a single value'
type: TypeError,
message: 'Header field "content-length" must only have a single value'
}
);

Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-http2-single-headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ server.listen(0, common.mustCall(() => {
() => client.request({ [i]: 'abc', [i.toUpperCase()]: 'xyz' }),
{
code: 'ERR_HTTP2_HEADER_SINGLE_VALUE',
type: Error,
message: `Header field "${i}" must have only a single value`
type: TypeError,
message: `Header field "${i}" must only have a single value`
}
);

common.expectsError(
() => client.request({ [i]: ['abc', 'xyz'] }),
{
code: 'ERR_HTTP2_HEADER_SINGLE_VALUE',
type: Error,
message: `Header field "${i}" must have only a single value`
type: TypeError,
message: `Header field "${i}" must only have a single value`
}
);
});
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-http2-util-headers-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ const {

common.expectsError({
code: 'ERR_HTTP2_HEADER_SINGLE_VALUE',
type: Error,
message: 'Header field ":status" must have only a single value'
type: TypeError,
message: 'Header field ":status" must only have a single value'
})(mapToHeaders(headers));
}

Expand Down Expand Up @@ -223,7 +223,7 @@ const {
HTTP2_HEADER_USER_AGENT,
HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS
].forEach((name) => {
const msg = `Header field "${name}" must have only a single value`;
const msg = `Header field "${name}" must only have a single value`;
common.expectsError({
code: 'ERR_HTTP2_HEADER_SINGLE_VALUE',
message: msg
Expand Down

0 comments on commit ef07d65

Please sign in to comment.