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: remove unused internal error constructors #19203

Closed
wants to merge 4 commits into from

Conversation

targos
Copy link
Member

@targos targos commented Mar 7, 2018

First commit removes exports for internal error constructors. Now all internal errors must be thrown using the new system: throw new errors.codes.MY_ERROR('xxx') instead of throw new errors.Error('MY_ERROR', 'xxx').

Second commit updates the internal errors documentation following this change.

@BridgeAR I tried to move SystemError to makeNodeErrorWithCode but it's not obvious to me how that could be done because the error code is not fixed, so I left it as is for now.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. errors Issues and PRs related to JavaScript errors originated in Node.js core. labels Mar 7, 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.

LGTM, just a suggestion to have a stricter test.


{
const err = new errors.Error('TEST_ERROR_1', 'test');
const err = new errors.codes.TEST_ERROR_1('test');
assert(err instanceof Error);
Copy link
Member

Choose a reason for hiding this comment

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

When being on it: this is actually not a good test because e.g., TypeError is going to be instanceof Error as well. I would change that to test for the name.

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 error name is checked on the line below this one

@BridgeAR
Copy link
Member

BridgeAR commented Mar 7, 2018

@targos true, seems like we should consider reworking SystemError. But that is of course out of the scope of this PR.

@targos targos force-pushed the port-errors-doc branch from 50463a4 to c6c904e Compare March 8, 2018 08:14
@targos
Copy link
Member Author

targos commented Mar 8, 2018

I pushed two small fixes.

CI: https://ci.nodejs.org/job/node-test-pull-request/13583/

@targos
Copy link
Member Author

targos commented Mar 10, 2018

Landed in 7314b17...0eec073

@targos targos closed this Mar 10, 2018
targos added a commit that referenced this pull request Mar 10, 2018
PR-URL: #19203
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
targos added a commit that referenced this pull request Mar 10, 2018
PR-URL: #19203
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@targos targos deleted the port-errors-doc branch March 10, 2018 11:47
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
PR-URL: nodejs#19203
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
PR-URL: nodejs#19203
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. errors Issues and PRs related to JavaScript errors originated in Node.js core.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants