From eca95a9ea5e5a1773bfa9343273f449e7f1df711 Mon Sep 17 00:00:00 2001 From: davidmarkclements Date: Thu, 12 Apr 2018 20:37:11 +0200 Subject: [PATCH] errors: alter ERR_INVALID_PROTOCOL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes the base instance for ERR_INVALID_PROTOCOL from Error to TypeError as a more accurate representation of the error. PR-URL: https://github.com/nodejs/node/pull/19983 Reviewed-By: James M Snell Reviewed-By: Michaƫl Zasso Reviewed-By: Ruben Bridgewater Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat Reviewed-By: Tiancheng "Timothy" Gu --- lib/internal/errors.js | 6 +++--- .../test-http-url.parse-only-support-http-https-protocol.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 2bc2c7bce57af5..c4dcb9ac5f6467 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -896,9 +896,9 @@ E('ERR_INVALID_OPT_VALUE_ENCODING', 'The value "%s" is invalid for option "encoding"', TypeError); E('ERR_INVALID_PERFORMANCE_MARK', 'The "%s" performance mark has not been set', Error); - -// This should probably be a `TypeError`. -E('ERR_INVALID_PROTOCOL', 'Protocol "%s" not supported. Expected "%s"', Error); +E('ERR_INVALID_PROTOCOL', + 'Protocol "%s" not supported. Expected "%s"', + TypeError); E('ERR_INVALID_REPL_EVAL_CONFIG', 'Cannot specify both "breakEvalOnSigint" and "eval" for REPL', TypeError); E('ERR_INVALID_SYNC_FORK_INPUT', diff --git a/test/parallel/test-http-url.parse-only-support-http-https-protocol.js b/test/parallel/test-http-url.parse-only-support-http-https-protocol.js index 986f75d3076434..5df547594b8450 100644 --- a/test/parallel/test-http-url.parse-only-support-http-https-protocol.js +++ b/test/parallel/test-http-url.parse-only-support-http-https-protocol.js @@ -38,7 +38,7 @@ invalidUrls.forEach((invalid) => { () => { http.request(url.parse(invalid)); }, { code: 'ERR_INVALID_PROTOCOL', - type: Error + type: TypeError } ); });