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

lib: port errors to new system #19034

Closed
wants to merge 29 commits into from
Closed

lib: port errors to new system #19034

wants to merge 29 commits into from

Conversation

targos
Copy link
Member

@targos targos commented Feb 27, 2018

This is a first batch of updates that touches non-underscored modules in /lib/.

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)

all subsystems :)

/cc @joyeecheung @BridgeAR @jasnell

@targos targos added semver-major PRs that contain breaking changes and should be released in the next major version. lib / src Issues and PRs related to general changes in the lib or src directory. errors Issues and PRs related to JavaScript errors originated in Node.js core. labels Feb 27, 2018
@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Feb 27, 2018
Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes itself LG by briefly scanning over it but I personally would remove the BC.

fail('windowsHide', __dirname, invalidArgTypeError);
fail('windowsHide', [], invalidArgTypeError);
fail('windowsHide', {}, invalidArgTypeError);
fail('windowsHide', common.mustNotCall(), invalidArgTypeError);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not failing? I expected that the invalidArgTypeError call number has to be changed otherwise?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible. It was failing because I forgot to update it, but then I forgot to run it again

@@ -74,7 +74,7 @@ const re = /^The "id" argument must be of type string\. Received type \w+$/;
common.expectsError(
() => { require(''); },
{
type: Error,
type: RangeError,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without changing the errors that result in such changes, the PR would be a patch. I personally prefer a PR that is possible to backport instead of having the PR as semver-major because just very few cases that were wrong before.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove the semver-major changes, but I think a backport would have to be done from scratch anyway, even for v9.x, because many error codes don't exist in any release line

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most errors were already ported in 9.x as far as I know. I personally still think it would be better to have this as a semver-patch but I am fine with it if others want to land it as is.

lib/module.js Outdated
throw new errors.Error('ERR_INVALID_ARG_VALUE',
'id', id, 'must be a non-empty string');
throw new ERR_INVALID_ARG_VALUE.RangeError('id', id,
'must be a non-empty string');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it seems like this is a TypeError, not a RangeError. Don't you think so?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type is checked just before. I don't feel strongly about it but it seemed right to throw a RangeError: the must be greater than zero

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I guess it is somewhat of a edge case. I do not feel strongly about it either.

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 usually we just go with ERR_OUT_OF_RANGE for this sort of generic range errors..probably makes more sense if it's ERR_INVALID_ARG_VALUE.Error on id, or a ERR_OUT_OF_RANGE on id.length

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to a TypeError. @joyeecheung are you OK with that?

@@ -74,7 +74,7 @@ const re = /^The "id" argument must be of type string\. Received type \w+$/;
common.expectsError(
() => { require(''); },
{
type: Error,
type: RangeError,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most errors were already ported in 9.x as far as I know. I personally still think it would be better to have this as a semver-patch but I am fine with it if others want to land it as is.

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but needs a rebase

@targos
Copy link
Member Author

targos commented Mar 2, 2018

@targos
Copy link
Member Author

targos commented Mar 4, 2018

Rebased again. Hopefully last CI: https://ci.nodejs.org/job/node-test-pull-request/13484/

@BridgeAR
Copy link
Member

BridgeAR commented Mar 4, 2018

As a question: shall we squash this or land each on it's own? I am fine both ways, I just thought I ask because it is a lot of commits.

@targos
Copy link
Member Author

targos commented Mar 4, 2018

I'm for squashing

@targos targos added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 4, 2018
@targos
Copy link
Member Author

targos commented Mar 5, 2018

And another CI: https://ci.nodejs.org/job/node-test-pull-request/13509/

There is no single green result but no failure seem related or reproducible so I'm going to land this.

targos added a commit that referenced this pull request Mar 5, 2018
This is a first batch of updates that touches non-underscored modules in
lib.

PR-URL: #19034
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
@targos
Copy link
Member Author

targos commented Mar 5, 2018

Squashed and landed in 1e8d110

@targos targos closed this Mar 5, 2018
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
This is a first batch of updates that touches non-underscored modules in
lib.

PR-URL: nodejs#19034
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
@targos targos deleted the port-errors branch October 17, 2020 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. errors Issues and PRs related to JavaScript errors originated in Node.js core. lib / src Issues and PRs related to general changes in the lib or src directory. 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.

5 participants