-
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
src, os, dgram, tty: migrate to internal errors #16567
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', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this for avoiding changing the error type? Maybe a comment because this looks a bit odd at first? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I really dislike how this was done, but I want to save it for a different PR to change it. |
||
new errors.SystemError(ctx)); | ||
} | ||
return ret; | ||
} | ||
|
||
Socket.prototype.bind = function(port_, address_ /*, callback*/) { | ||
|
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.data
property (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 pickinfo
instead 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
*.info
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.
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