GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lib: new error implementation by BridgeAR · Pull Request #18857 · nodejs/node

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Feb 18, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This implements a function based error system. Instead of passing in the
error code as first argument, the error code itself is a error class.
It already contains the correct error type, so while adding a new
error no one has to think about the error type anymore. In case a
single error code has more than one error type, the error class has
properties for the non default error types. Those can be used as
fallback.

This prevents typos, makes the implementation easier and it is less
verbose when writing the code for a new error.

The implementation itself does not interfere with the old
implementation. So the old and the new system can co-exist and it is
possible to slowly migrate the old ones to the new system.

By doing this I also realized that there are multiple error codes that
are currently not used at all. I also found other mistakes where a
wrong error type was in place.

So far this is only WIP and I wanted to get some feedback.

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
Affected core subsystem(s)

lib

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@BridgeAR
BridgeAR requested review from jasnell and joyeecheung February 18, 2018 20:26
@nodejs-github-bot nodejs-github-bot added console Issues and PRs related to the console subsystem. errors Issues and PRs related to JavaScript errors originating in Node.js core. module Issues and PRs related to the module subsystem. labels Feb 18, 2018
@BridgeAR BridgeAR added the wip Issues and PRs that are still a work in progress. label Feb 18, 2018
addaleax
addaleax approved these changes Feb 18, 2018
View reviewed changes
Comment thread lib/internal/errors.js Outdated

@addaleax addaleax Feb 18, 2018

Copy link
Copy Markdown
Member

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.

In this case we might also want to create a static get name() so that the class itself can be disambiguated from other classes of this type?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@TimothyGu TimothyGu Feb 19, 2018

Copy link
Copy Markdown
Member

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.

Or even better, NodeError.name = ....

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@BridgeAR BridgeAR Feb 19, 2018

Copy link
Copy Markdown
Member Author

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 thought about this a few times now and I decided not to do that out of the following reasons:

  1. We only use the class internal and do not expose it directly.
  2. The main class has sub classes as properties and those should make it easy to identify the correct one.
  3. If we add the name, the original NodeError name will not be there and I think it should be.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
devsnek
devsnek reviewed Feb 18, 2018
View reviewed changes
Comment thread lib/internal/errors.js Outdated

@devsnek devsnek Feb 18, 2018

Copy link
Copy Markdown
Member

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.

is there any use case for this?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mscdex mscdex Feb 18, 2018

Copy link
Copy Markdown
Contributor

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.

My guess is that userland modules (not aware of the standardized node core error objects) may have already been setting this property to something else.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jasnell jasnell Feb 18, 2018

Copy link
Copy Markdown
Member

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.

Yes, this was specifically asked for by userland module authors who need the ability to keep specifying their own codes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
devsnek
devsnek approved these changes Feb 18, 2018
View reviewed changes

@devsnek devsnek left a comment

Copy link
Copy Markdown
Member

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 addaleax's comment addressed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jasnell
jasnell reviewed Feb 18, 2018
View reviewed changes
Comment thread lib/console.js Outdated

@jasnell jasnell Feb 18, 2018

Copy link
Copy Markdown
Member

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.

The only challenge I really have with this is that it makes it far less obvious what kind of error is being thrown here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@BridgeAR BridgeAR Feb 19, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

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.

That is also the charming side: you do not have to care about that as it was already taken care off in an earlier step. And we can verify much better that it actually has the correct type. Now you can see the types in the overview in the errors.js file. And I spotted multiple errors due to this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

devsnek reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
jasnell
jasnell approved these changes Feb 18, 2018
View reviewed changes
BridgeAR added 5 commits February 19, 2018 01:49
@BridgeAR
errors: implement new error handling
690d6f5
This implements a function based system. Instead of passing in the
error code as first argument, the error code itself is a error class.
It already contains the correct error type, so while adding a new
error no one has to think about the error type anymore. In case a
single error code has more than one error type, the error class has
properties for the non default error types. Those can be used as
fallback.

This prevents typos, makes the implementation easier and it is less
verbose when writing the code for a new error.

The implementation itself does not interfere with the old
implementation. So the old and the new system can co-exist and it is
possible to slowly migrate the old ones to the new system.
@BridgeAR
errors: update all internal errors
cc0edb9
This updates all internal errors to the new error type. While doing
so it removes unused errors.

A few errors currently seem to have the wrong type. To identify them
later, comments were added next to the error type.
@BridgeAR
console: port errors to new system
a51e50d
This ports the errors to the new error system.
@BridgeAR
errors: add comments about falsy error types
ae87200
Some error types are not properly set. This adds comments which
ones are probably falty and to what they should be set instead.
@BridgeAR
errors: simplify sysError
474c498
@BridgeAR BridgeAR removed the wip Issues and PRs that are still a work in progress. label Feb 19, 2018
@BridgeAR
BridgeAR force-pushed the error-suggestion branch from df999dc to 474c498 Compare February 19, 2018 01:36
@BridgeAR

BridgeAR commented Feb 19, 2018

Copy link
Copy Markdown
Member Author

I updated all error codes and removed the breaking change. It can now be used for all error codes. I also added quite a few comments about wrong error types. Please have a look. I personally suggest to keep the comments for now and change those in a different PR as that is breaking.

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR BridgeAR added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Feb 19, 2018
@BridgeAR
fixup: nicer extra class implementation
5ee0ffb
joyeecheung
joyeecheung approved these changes Feb 19, 2018
View reviewed changes

@joyeecheung joyeecheung left a comment

Copy link
Copy Markdown
Member

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 a suggestion, thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/internal/errors.js Outdated
};
}

function makeNodeError2(Base, key) {

@joyeecheung joyeecheung Feb 19, 2018

Copy link
Copy Markdown
Member

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.

Can this be renamed to something more descriptive e.g. makeNodeErrorWithCode?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BridgeAR reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@BridgeAR

BridgeAR commented Feb 21, 2018

Copy link
Copy Markdown
Member Author

@mhdawson one NAPI code got removed that was not used (ERR_NAPI_CONS_PROTOTYPE_OBJECT). I checked every code that I removed and there are no hits anywhere for that code besides in the docs and errors.js. You can spot all removed error codes easily by looking at the documentation (I removed all of those from the documentation as well).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR
fixup: rename
e0df496
@BridgeAR

BridgeAR commented Feb 22, 2018

Copy link
Copy Markdown
Member Author

I changed the name. Running a Light-CI just to verify the minor changes since the full CI:

https://ci.nodejs.org/job/node-test-commit-light/307/console

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BridgeAR added a commit to BridgeAR/node that referenced this pull request Feb 22, 2018
@BridgeAR
errors: implement new error handling
8272c22
This implements a function based system. Instead of passing in the
error code as first argument, the error code itself is a error class.
It already contains the correct error type, so while adding a new
error no one has to think about the error type anymore. In case a
single error code has more than one error type, the error class has
properties for the non default error types. Those can be used as
fallback.

This prevents typos, makes the implementation easier and it is less
verbose when writing the code for a new error.

The implementation itself does not interfere with the old
implementation. So the old and the new system can co-exist and it is
possible to slowly migrate the old ones to the new system.

PR-URL: nodejs#18857
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
BridgeAR added a commit to BridgeAR/node that referenced this pull request Feb 22, 2018
@BridgeAR
errors: update all internal errors
6e1c25c
This updates all internal errors to the new error type. While doing
so it removes unused errors.

A few errors currently seem to have the wrong type. To identify them
later, comments were added next to the error type.

PR-URL: nodejs#18857
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
BridgeAR added a commit to BridgeAR/node that referenced this pull request Feb 22, 2018
@BridgeAR
console: port errors to new system
7c8beb5
This ports the errors to the new error system.

PR-URL: nodejs#18857
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
BridgeAR added a commit to BridgeAR/node that referenced this pull request Feb 22, 2018
@BridgeAR
errors: add comments about falsy error types
eb3edef
Some error types are not properly set. This adds comments which
ones are probably falty and to what they should be set instead.

PR-URL: nodejs#18857
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
BridgeAR added a commit to BridgeAR/node that referenced this pull request Feb 22, 2018
@BridgeAR
errors: simplify sysError
95bae85
PR-URL: nodejs#18857
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
@BridgeAR @MayaLekova
errors: simplify sysError
b5f5380
PR-URL: nodejs#18857
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
ChALkeR added a commit that referenced this pull request Jun 23, 2018
@ChALkeR
errors: fix ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK
bd6bb89
This restores a broken and erroneously removed error, which was
accidentially renamed to ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK (notice
the "INTST" vs "INST") in 921fb84
(PR #16874) and then had documentation and implementation removed under
the old name in 6e1c25c (PR #18857),
as it appeared unused.

This error code never worked or was documented under the mistyped name
ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK, so renaming it back to
ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK is a semver-patch fix.

Refs: #21440
Refs: #21470
Refs: #16874
Refs: #18857
This was referenced Jun 23, 2018
errors: fix ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK #21492
Closed
errors: fix ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK #21493
Closed
@ChALkeR ChALkeR mentioned this pull request Jun 25, 2018
doc: remove 2 unused error codes from errors.md #21491
Merged
2 of 4 tasks
targos pushed a commit to ChALkeR/io.js that referenced this pull request Jun 30, 2018
@ChALkeR @targos
errors: fix ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK
75bf6a8
This restores a broken and erroneously removed error, which was
accidentially renamed to ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK (notice
the "INTST" vs "INST") in 921fb84
(PR nodejs#16874) and then had documentation and implementation removed under
the old name in 6e1c25c (PR nodejs#18857),
as it appeared unused.

This error code never worked or was documented under the mistyped name
ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK, so renaming it back to
ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK is a semver-patch fix.

Refs: nodejs#21440
Refs: nodejs#21470
Refs: nodejs#16874
Refs: nodejs#18857
targos pushed a commit that referenced this pull request Jun 30, 2018
@ChALkeR @targos
errors: fix ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK
7bdc694
This restores a broken and erroneously removed error, which was
accidentially renamed to ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK (notice
the "INTST" vs "INST") in 921fb84
(PR #16874) and then had documentation and implementation removed under
the old name in 6e1c25c (PR #18857),
as it appeared unused.

This error code never worked or was documented under the mistyped name
ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK, so renaming it back to
ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK is a semver-patch fix.

Refs: #21440
Refs: #21470
Refs: #16874
Refs: #18857

PR-URL: #21493
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ron Korving <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
targos pushed a commit that referenced this pull request Jul 3, 2018
@ChALkeR @targos
errors: fix ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK
1e5afb7
This restores a broken and erroneously removed error, which was
accidentially renamed to ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK (notice
the "INTST" vs "INST") in 921fb84
(PR #16874) and then had documentation and implementation removed under
the old name in 6e1c25c (PR #18857),
as it appeared unused.

This error code never worked or was documented under the mistyped name
ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK, so renaming it back to
ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK is a semver-patch fix.

Refs: #21440
Refs: #21470
Refs: #16874
Refs: #18857

PR-URL: #21493
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ron Korving <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
@MylesBorins MylesBorins added the backport-requested-v8.x label Jul 31, 2018
@MylesBorins

MylesBorins commented Jul 31, 2018

Copy link
Copy Markdown
Contributor

Backport requested for 8.x in #19244

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR
BridgeAR deleted the error-suggestion branch April 1, 2019 23:38
This was referenced Aug 5, 2021
[Snyk] Fix for 1 vulnerabilities ron-a20/node#37
Open
[Snyk] Fix for 1 vulnerabilities aliceUnhinged613/node#30
Open
[Snyk] Fix for 1 vulnerabilities meghasfdc/node#40
Open
[Snyk] Fix for 1 vulnerabilities Rednickle/node-1#26
Open
[Snyk] Fix for 1 vulnerabilities kissofire/node#40
Open
[Snyk] Fix for 1 vulnerabilities 137717unity/node#31
Open
[Snyk] Fix for 1 vulnerabilities sitedata/node#30
Open
[Snyk] Fix for 1 vulnerabilities molllyn1/node#15
Open
@snyk-bot snyk-bot mentioned this pull request Aug 15, 2021
[Snyk] Fix for 1 vulnerabilities ron-a20/node#39
Open
@molllyn1 molllyn1 mentioned this pull request Mar 22, 2024
[Snyk] Fix for 2 vulnerabilities molllyn1/node#106
Open
@137717unity 137717unity mentioned this pull request Mar 22, 2024
[Snyk] Fix for 2 vulnerabilities 137717unity/node#122
Open
@kissofire kissofire mentioned this pull request Mar 22, 2024
[Snyk] Fix for 2 vulnerabilities kissofire/node#124
Open
@aliceUnhinged613 aliceUnhinged613 mentioned this pull request Mar 22, 2024
[Snyk] Fix for 2 vulnerabilities aliceUnhinged613/node#123
Open
@ron-a20 ron-a20 mentioned this pull request Mar 22, 2024
[Snyk] Fix for 2 vulnerabilities ron-a20/node#121
Open
@wedataintelligence wedataintelligence mentioned this pull request Mar 23, 2024
[Snyk] Fix for 2 vulnerabilities wedataintelligence/node#105
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell approved these changes
@addaleax addaleax addaleax approved these changes
@joyeecheung joyeecheung joyeecheung approved these changes
+3 more reviewers
@mscdex mscdex mscdex left review comments
@TimothyGu TimothyGu TimothyGu left review comments
@devsnek devsnek devsnek approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. console Issues and PRs related to the console subsystem. errors Issues and PRs related to JavaScript errors originating in Node.js core. module Issues and PRs related to the module subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

10 participants

@BridgeAR @MylesBorins @mscdex @jasnell @addaleax @TimothyGu @joyeecheung @devsnek @mhdawson @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.