-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
src, os, dgram, tty: migrate to internal errors #16567
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
Changes from all commits
7462524
5698a33
1863099
ee9e7a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -173,11 +173,13 @@ function bufferSize(self, size, buffer) { | |
| if (size >>> 0 !== size) | ||
| throw new errors.TypeError('ERR_SOCKET_BAD_BUFFER_SIZE'); | ||
|
|
||
| try { | ||
| return self._handle.bufferSize(size, buffer); | ||
| } catch (e) { | ||
| throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e); | ||
| const ctx = {}; | ||
| const ret = self._handle.bufferSize(size, buffer, ctx); | ||
| if (ret === undefined) { | ||
| throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', | ||
|
||
| new errors.SystemError(ctx)); | ||
| } | ||
| return ret; | ||
| } | ||
|
|
||
| Socket.prototype.bind = function(port_, address_ /*, callback*/) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Come to think of it, I think a more popular pattern in the userland is using the
err.dataproperty (correct me if I am wrong), I remember seeing some logging services/tools collect that automatically in addition toerr.code...I remember there is another PR for crypto that useinfo. Is there a reason that we pickinfoinstead ofdata?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.
A quick search in our own code base shows that eslint is using
error.data: https://github.com/nodejs/node/blob/master/tools/eslint/lib/config/config-validator.js#L92 and https://github.com/nodejs/node/blob/master/tools/eslint/lib/config/config-validator.js#L179There 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've seen both: https://www.npmjs.com/package/verror uses
*.infoThere 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.
On a side note: would be easier to read if we have a syntax for documenting optional properties..
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 agree, definitely something worth working on