From ef07d6570f1c6345b7f991ca2d986dec6a481350 Mon Sep 17 00:00:00 2001 From: davidmarkclements Date: Wed, 4 Apr 2018 19:36:04 +0200 Subject: [PATCH] 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 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Matteo Collina --- lib/internal/errors.js | 3 +-- test/parallel/test-http2-multi-content-length.js | 4 ++-- test/parallel/test-http2-single-headers.js | 8 ++++---- test/parallel/test-http2-util-headers-list.js | 6 +++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index f7c444afb23caf..99ffb46783b8cb 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -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); diff --git a/test/parallel/test-http2-multi-content-length.js b/test/parallel/test-http2-multi-content-length.js index c64b803a0ecca3..7d8ff4858fedbb 100644 --- a/test/parallel/test-http2-multi-content-length.js +++ b/test/parallel/test-http2-multi-content-length.js @@ -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' } ); diff --git a/test/parallel/test-http2-single-headers.js b/test/parallel/test-http2-single-headers.js index c545b065015050..37eaf8b17c8f28 100644 --- a/test/parallel/test-http2-single-headers.js +++ b/test/parallel/test-http2-single-headers.js @@ -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` } ); }); diff --git a/test/parallel/test-http2-util-headers-list.js b/test/parallel/test-http2-util-headers-list.js index 0ff6b558d9a51b..0e5c519264de7b 100644 --- a/test/parallel/test-http2-util-headers-list.js +++ b/test/parallel/test-http2-util-headers-list.js @@ -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