Skip to content

Commit b40efa4

Browse files
davidmarkclementsjasnell
authored andcommitted
errors: alter ERR_INVALID_IP_ADDRESS
changes the base instance for ERR_INVALID_IP_ADDRESS from Error to TypeError as a more accurate representation of the error. PR-URL: #19979 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent c9bb91a commit b40efa4

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

lib/dns.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ function setServers(servers) {
316316
return newSet.push([ipVersion, s, parseInt(p)]);
317317
}
318318

319-
throw new ERR_INVALID_IP_ADDRESS.Error(serv);
319+
throw new ERR_INVALID_IP_ADDRESS(serv);
320320
});
321321

322322
const errorNumber = this._handle.setServers(newSet);

lib/internal/errors.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,7 @@ E('ERR_INVALID_FILE_URL_HOST',
891891
E('ERR_INVALID_FILE_URL_PATH', 'File URL path %s', TypeError);
892892
E('ERR_INVALID_HANDLE_TYPE', 'This handle type cannot be sent', TypeError);
893893
E('ERR_INVALID_HTTP_TOKEN', '%s must be a valid HTTP token ["%s"]', TypeError);
894-
// The `Error` should probably be a `TypeError`.
895-
E('ERR_INVALID_IP_ADDRESS', 'Invalid IP address: %s', TypeError, Error);
894+
E('ERR_INVALID_IP_ADDRESS', 'Invalid IP address: %s', TypeError);
896895
E('ERR_INVALID_OPT_VALUE', (name, value) =>
897896
`The value "${String(value)}" is invalid for option "${name}"`,
898897
TypeError,

test/parallel/test-dns.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ dns.setServers(goog);
7070
assert.deepStrictEqual(dns.getServers(), goog);
7171
common.expectsError(() => dns.setServers(['foobar']), {
7272
code: 'ERR_INVALID_IP_ADDRESS',
73-
type: Error,
73+
type: TypeError,
7474
message: 'Invalid IP address: foobar'
7575
});
7676
common.expectsError(() => dns.setServers(['127.0.0.1:va']), {
7777
code: 'ERR_INVALID_IP_ADDRESS',
78-
type: Error,
78+
type: TypeError,
7979
message: 'Invalid IP address: 127.0.0.1:va'
8080
});
8181
assert.deepStrictEqual(dns.getServers(), goog);

0 commit comments

Comments
 (0)