From 3bdd8e51ee5c5622c5a48cff6580eb642953b05d 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. --- 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 99ffb46783b8cb..4d9362a5cf5a79 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -804,9 +804,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 9a5567aab897f8..0ddd72b374694c 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' + }); }); }); }