-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dns, errors: Migrate to use internal/errors #14212
Conversation
ebfd843
to
be61d5d
Compare
doc/api/errors.md
Outdated
@@ -580,6 +580,10 @@ by the `assert` module. | |||
|
|||
Used when attempting to perform an operation outside the bounds of a `Buffer`. | |||
|
|||
<a id="ERR_CARES_FAILED"></a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps ERR_DNS_SET_SERVERS_FAILED
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very close! thank for doing this. Left a comment I'd like to see addressed.
1ae02d3
to
56d8131
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if CI is green.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
One failure in CI looks unrelated.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits
lib/dns.js
Outdated
throw new TypeError('Invalid arguments: ' + | ||
'hostname must be a string or falsey'); | ||
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'hostname', | ||
['string', 'falsey'], hostname); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new indentation rule requires aligning to the call (
#14403
lib/dns.js
Outdated
@@ -290,13 +292,14 @@ function resolve(hostname, rrtype, callback) { | |||
resolver = resolveMap.A; | |||
callback = rrtype; | |||
} else { | |||
throw new TypeError('"rrtype" argument must be a string'); | |||
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'rrtype', | |||
'string', rrtype); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i
lib/internal/errors.js
Outdated
@@ -113,6 +113,10 @@ E('ERR_BUFFER_OUT_OF_BOUNDS', bufferOutOfBounds); | |||
E('ERR_CONSOLE_WRITABLE_STREAM', | |||
'Console expects a writable stream instance for %s'); | |||
E('ERR_CPU_USAGE', 'Unable to obtain cpu usage %s'); | |||
E('ERR_DNS_SET_SERVERS_FAILED', | |||
(err, servers) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably better (err, servers) => `c-ares failed to set servers: "${err}" [${servers}]`
test/parallel/test-c-ares.js
Outdated
// Try calling resolve with an unsupported type that's an object key | ||
'toString' | ||
].forEach((val) => { | ||
assert.throws(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New feature of expectsError
can be used without assert.throws
:
common.expectsError(
dns.resolve('www.google.com', val),
{
code: 'ERR_INVALID_OPT_VALUE',
type: TypeError,
message: `The value "${val}" is invalid for option "rrtype"`
}
);
doc/api/errors.md
Outdated
@@ -591,6 +591,10 @@ Used when `Console` is instantiated without `stdout` stream or when `stdout` or | |||
|
|||
Used when the native call from `process.cpuUsage` cannot be processed properly. | |||
|
|||
<a id="ERR_DNS_SET_SERVERS_FAILED"></a> | |||
|
|||
Used when `c-ares` failed to set the server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used when `c-ares` failed to set the DNS servers.
56d8131
to
0653452
Compare
Pushed commit to address comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@starkwang thank you. |
Landed in 9cb390d |
PR-URL: #14212 Refs: #11273 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Khaidi Chu <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Migrate dns errors to use internal/errors.
Ref: #11273
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
dns, errors