Skip to content

Commit

Permalink
errors: alter ERR_INVALID_IP_ADDRESS
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
davidmarkclements authored and jasnell committed Apr 16, 2018
1 parent c9bb91a commit b40efa4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ function setServers(servers) {
return newSet.push([ipVersion, s, parseInt(p)]);
}

throw new ERR_INVALID_IP_ADDRESS.Error(serv);
throw new ERR_INVALID_IP_ADDRESS(serv);
});

const errorNumber = this._handle.setServers(newSet);
Expand Down
3 changes: 1 addition & 2 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,7 @@ E('ERR_INVALID_FILE_URL_HOST',
E('ERR_INVALID_FILE_URL_PATH', 'File URL path %s', TypeError);
E('ERR_INVALID_HANDLE_TYPE', 'This handle type cannot be sent', TypeError);
E('ERR_INVALID_HTTP_TOKEN', '%s must be a valid HTTP token ["%s"]', TypeError);
// The `Error` should probably be a `TypeError`.
E('ERR_INVALID_IP_ADDRESS', 'Invalid IP address: %s', TypeError, Error);
E('ERR_INVALID_IP_ADDRESS', 'Invalid IP address: %s', TypeError);
E('ERR_INVALID_OPT_VALUE', (name, value) =>
`The value "${String(value)}" is invalid for option "${name}"`,
TypeError,
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ dns.setServers(goog);
assert.deepStrictEqual(dns.getServers(), goog);
common.expectsError(() => dns.setServers(['foobar']), {
code: 'ERR_INVALID_IP_ADDRESS',
type: Error,
type: TypeError,
message: 'Invalid IP address: foobar'
});
common.expectsError(() => dns.setServers(['127.0.0.1:va']), {
code: 'ERR_INVALID_IP_ADDRESS',
type: Error,
type: TypeError,
message: 'Invalid IP address: 127.0.0.1:va'
});
assert.deepStrictEqual(dns.getServers(), goog);
Expand Down

0 comments on commit b40efa4

Please sign in to comment.