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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
davidmarkclements 2018-04-04 19:36:04 +02:00 committed by Matteo Collina
parent add1c02bda
commit ef07d6570f
4 changed files with 10 additions and 11 deletions

View File

@ -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);

View File

@ -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'
}
);

View File

@ -31,8 +31,8 @@ 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`
}
);
@ -40,8 +40,8 @@ server.listen(0, common.mustCall(() => {
() => 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`
}
);
});

View File

@ -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));
}
@ -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