-
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
buffer: convert buffer.transcode
to use internal/errors
#16352
Conversation
lib/buffer.js
Outdated
@@ -1562,7 +1562,8 @@ if (process.binding('config').hasIntl) { | |||
// Buffer instance. | |||
transcode = function transcode(source, fromEncoding, toEncoding) { | |||
if (!isUint8Array(source)) | |||
throw new TypeError('"source" argument must be a Buffer or Uint8Array'); | |||
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'source', | |||
['buffer', 'uint8Array'], source); |
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.
please capitalize Buffer and Uint8Array.
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.
Most of the ERR_INVALID_ARG_TYPE
errors in lib
are using lower case.
For example:
https://github.com/nodejs/node/blob/master/lib/buffer.js#L198
https://github.com/nodejs/node/blob/master/lib/buffer.js#L225
https://github.com/nodejs/node/blob/master/lib/util.js#L965
Here is just for unitarity. It may need another PR to capitalize them.
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 we should follow the convention of the docs here (lower case for primitives and capitals for others..)
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.
Those existing uses really ought to have been capitalized, we just missed them on the review, unfortunately.
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 with the buffer
and uint8array
changed to Buffer
and Uint8Array
`buffer.transcode` is still using raw TypeError. This change is to convert it to use internal/errors. Ref: nodejs#11273
da00b76
to
0117db7
Compare
Pushed commit to address comment. |
`buffer.transcode` is still using raw TypeError. This change is to convert it to use internal/errors. Ref: #11273 PR-URL: #16352 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Landed in e79a61c , thanks for the contribution! |
I added the |
`buffer.transcode` is still using raw TypeError. This change is to convert it to use internal/errors. Ref: nodejs/node#11273 PR-URL: nodejs/node#16352 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
`buffer.transcode` is still using raw TypeError. This change is to convert it to use internal/errors. Ref: nodejs/node#11273 PR-URL: nodejs/node#16352 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
buffer.transcode
is still using raw TypeError. This change is to convert it to useinternal/errors
.Ref: #11273
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
buffer