From 345e3b28c6aee09b86311f5bcc23fbe818f1ea4c Mon Sep 17 00:00:00 2001 From: davidmarkclements Date: Thu, 12 Apr 2018 02:34:59 +0200 Subject: [PATCH] errors: alter ERR_INVALID_DOMAIN_NAME Changes the base instance for ERR_INVALID_DOMAIN_NAME from Error to TypeError as a more accurate representation of the error. PR-URL: https://github.com/nodejs/node/pull/19961 Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Luigi Pinca Reviewed-By: Matteo Collina --- lib/internal/errors.js | 4 +--- test/parallel/test-http-invalid-urls.js | 5 ++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 35c3fb74b08..8505ec39b68 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -878,9 +878,7 @@ E('ERR_INVALID_CHAR', invalidChar, TypeError); // This should probably be a `TypeError`. E('ERR_INVALID_CURSOR_POS', 'Cannot set cursor row without setting its column', Error); - -// This should probably be a `TypeError`. -E('ERR_INVALID_DOMAIN_NAME', 'Unable to determine the domain name', Error); +E('ERR_INVALID_DOMAIN_NAME', 'Unable to determine the domain name', TypeError); E('ERR_INVALID_FD', '"fd" must be a positive integer: %s', RangeError); E('ERR_INVALID_FD_TYPE', 'Unsupported fd type: %s', TypeError); diff --git a/test/parallel/test-http-invalid-urls.js b/test/parallel/test-http-invalid-urls.js index 9a5567aab89..0ddd72b3746 100644 --- a/test/parallel/test-http-invalid-urls.js +++ b/test/parallel/test-http-invalid-urls.js @@ -19,7 +19,10 @@ function test(host) { `${module}.${fn} should not connect to ${host}` ); const throws = () => { modules[module][fn](host, doNotCall); }; - common.expectsError(throws, { code: 'ERR_INVALID_DOMAIN_NAME' }); + common.expectsError(throws, { + type: TypeError, + code: 'ERR_INVALID_DOMAIN_NAME' + }); }); }); }