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

@nodejs-github-bot nodejs-github-bot added the buffer Issues and PRs related to the buffer subsystem. label 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);
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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..)

Copy link
Member

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.

Copy link
Member

@jasnell jasnell left a 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
@starkwang
Copy link
Contributor Author

Pushed commit to address comment.

@joyeecheung
Copy link
Member

@joyeecheung joyeecheung added the errors Issues and PRs related to JavaScript errors originated in Node.js core. label Oct 23, 2017
gireeshpunathil pushed 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

Landed in e79a61c , thanks for the contribution!

@targos targos added the semver-major PRs that contain breaking changes and should be released in the next major version. label Oct 23, 2017
@targos
Copy link
Member

targos commented Oct 23, 2017

I added the semver-major label

addaleax pushed 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 pushed 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
Labels
buffer Issues and PRs related to the buffer subsystem. errors Issues and PRs related to JavaScript errors originated in Node.js core. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants