-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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, net, internal/net: migrate to internals/error #11738
Conversation
var msg = `The "${name}" argument must be `; | ||
if (Array.isArray(expected)) { | ||
var len = expected.length; | ||
expected = expected.map((i) => String(i)); |
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.
Avoid these functional Array methods for performance.
msg += `. Received ${actual !== null ? typeof actual : 'null'}`; | ||
} | ||
return msg; | ||
} |
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.
Missing newline at end of file.
|
||
When present (e.g. in `net` or `dgram`), the `error.address` property is a string | ||
describing the address to which the connection failed. | ||
|
||
#### error.port | ||
|
||
* {Number} | ||
* {number} |
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.
These kinds of changes should be in a separate commit.
[online]: http://man7.org/linux/man-pages/man3/errno.3.html | ||
[stream-based]: stream.html | ||
[syscall]: http://man7.org/linux/man-pages/man2/syscall.2.html | ||
[try-catch]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch | ||
[V8's stack trace API]: https://github.com/v8/v8/wiki/Stack-Trace-API | ||
[vm]: vm.html | ||
[vm]: vm.html |
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.
What's this change?
@@ -255,9 +255,16 @@ will affect any stack trace captured *after* the value has been changed. | |||
If set to a non-number value, or set to a negative number, stack traces will | |||
not capture any frames. | |||
|
|||
### error.message | |||
#### error.code |
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.
Why is this being duplicated? error.code
already exists below.
} else if (typeof options === 'function') { | ||
callback = options; | ||
family = 0; | ||
} else if (typeof callback !== 'function') { | ||
throw new TypeError('Invalid arguments: callback must be passed'); | ||
// throw new TypeError('Invalid arguments: callback must be passed'); |
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.
This needs to be removed.
err === uv.UV_EAI_NODATA || | ||
err === uv.UV_EAI_NONAME) { | ||
err === uv.UV_EAI_NODATA || | ||
err === uv.UV_EAI_NONAME) { |
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.
This should be reverted, the conditionals should be lined up.
hints !== cares.AI_V4MAPPED && | ||
hints !== (cares.AI_ADDRCONFIG | cares.AI_V4MAPPED)) { | ||
throw new TypeError('Invalid argument: hints must use valid flags'); | ||
hints !== cares.AI_ADDRCONFIG && |
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.
Ditto about reverting the indentation changes.
// Add new errors from here... | ||
|
||
// Errors from 111294, port error from 11302 |
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 think 111294
here should be 11294
instead? Also it's a little bit vague about what this comment is referring to, perhaps it can just be removed?
var msg = `The "${name}" argument must be `; | ||
if (Array.isArray(expected)) { | ||
var len = expected.length; | ||
expected = expected.map((i) => String(i)); |
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.
Ditto about Array methods.
@@ -975,7 +975,8 @@ function lookupAndConnect(self, options) { | |||
} | |||
|
|||
if (options.lookup && typeof options.lookup !== 'function') | |||
throw new TypeError('"lookup" option should be a function'); | |||
// throw new TypeError('"lookup" option should be a function'); |
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.
This needs to be removed.
the other migrations were done module by module, perhaps this should be two PRs, Also, the first commit doesn't follow git commit format guidelines, and the doc change has to be a different PR, its not semver-major, putting it in this PR means it won't be backported. |
@sam-github: i was working on about the docs, i should remove from this PR and create a new one dedicated to it, right? |
@jasnell was leading the errors stuff, he should weigh in. My suggestion would be to
if dns and net are so intertwined they have to be updated together, then one commit |
Please separate the internal errors stuff into a separate pr. I'll be tackling those next week |
@jasnell can you clarify how should i proceed with this? i was going to separate the doc from the PR but every other PR in the migration have docs with it, so I am confused About separating internal errors stuff in another PR, you mean internal/net? Even if it breaks the tests? |
@sousandrei Can you rebase? Tests should always work after in every single commit. Documentation changes should go with the relevant code changes in 1 PR. PRs that address a different problem or are a separate refactoring should be in a separate PR. |
I'm closing this because it's been inactive for quite a while. Feel free to reopen or ping a collaborator to get it reopened if needed. |
Error codes reused and respective PRs:
#11294
#11302
Ref: #11273
Semver-major because this updates specific error messages and converts errors over to use the new internal/errors.js mechanism.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
errors, net, dns, doc