Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

@starkwang
Copy link
Contributor

@starkwang starkwang commented Oct 21, 2017

buffer.transcode is still using raw TypeError. This change is to convert it to use internal/errors.

Ref: #11273

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

buffer

@targos
targos approved these changes Oct 21, 2017
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);

This comment has been minimized.

@targos

targos Oct 21, 2017
Member

please capitalize Buffer and Uint8Array.

This comment has been minimized.

@starkwang

starkwang Oct 21, 2017
Author Contributor

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.

This comment has been minimized.

@joyeecheung

joyeecheung Oct 21, 2017
Member

I think we should follow the convention of the docs here (lower case for primitives and capitals for others..)

This comment has been minimized.

@jasnell

jasnell Oct 22, 2017
Member

Those existing uses really ought to have been capitalized, we just missed them on the review, unfortunately.

@lpinca
lpinca approved these changes Oct 21, 2017
Copy link
Member

@jasnell jasnell left a comment

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: #11273
@starkwang starkwang force-pushed the starkwang:buffer-transcode-error branch to 0117db7 Oct 22, 2017
@starkwang
Copy link
Contributor Author

@starkwang starkwang commented Oct 22, 2017

Pushed commit to address comment.

@joyeecheung joyeecheung added the errors label Oct 23, 2017
gireeshpunathil added a commit that referenced this pull request Oct 23, 2017
`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>
@gireeshpunathil
Copy link
Member

@gireeshpunathil gireeshpunathil commented Oct 23, 2017

Landed in e79a61c , thanks for the contribution!

@targos
Copy link
Member

@targos targos commented Oct 23, 2017

I added the semver-major label

addaleax added a commit to ayojs/ayo that referenced this pull request Oct 26, 2017
`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>
addaleax added a commit to ayojs/ayo that referenced this pull request Dec 7, 2017
`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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants
You can’t perform that action at this time.