Skip to content

util: improve internal isError() validation - #24746

Closed
BridgeAR wants to merge 5 commits into
nodejs:masterfrom
BridgeAR:improve-is-error
Closed

util: improve internal isError() validation#24746
BridgeAR wants to merge 5 commits into
nodejs:masterfrom
BridgeAR:improve-is-error

Conversation

@BridgeAR

@BridgeARBridgeAR commented Nov 30, 2018

Copy link
Copy Markdown
Member

The current internal isError function checked the toString value
instead of using the more precise util.types.isNativeError() check.
The instanceof check is not removed due to possible errors that
are not native but still an instance of Error.

The internal isError function is only used in util.inspect() and the repl.

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

The current internal isError function checked the toString value
instead of using the more precise `util.types.isNativeError()` check.
The `instanceof` check is not removed due to possible errors that
are not native but still an instance of Error.
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-botnodejs-github-bot added the util Issues and PRs related to the built-in util module. label Nov 30, 2018
@BridgeAR

Copy link
Copy Markdown
MemberAuthor

@sam-githubsam-github left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this should have some unit tests, specifically, some that failed before the change and succeed afterwards. My js isn't good enough, I don't understand the subtleties of how it is becoming more precise, and was hoping to learn what corner cases are better covered from the tests.

Comment threadlib/util.js
@BridgeAR

Copy link
Copy Markdown
MemberAuthor

I just pushed some tests as well.

@BridgeAR

Copy link
Copy Markdown
MemberAuthor

@nodejs/util PTAL

Comment threadlib/internal/util.js
Comment threadtest/parallel/test-internal-util-helpers.js
@BridgeAR

Copy link
Copy Markdown
MemberAuthor

@BridgeARBridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 2, 2018
BridgeAR added a commit to BridgeAR/node that referenced this pull request Dec 3, 2018
The current internal isError function checked the toString value
instead of using the more precise `util.types.isNativeError()` check.
The `instanceof` check is not removed due to possible errors that
are not native but still an instance of Error.
PR-URL: nodejs#24746
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
@BridgeAR

Copy link
Copy Markdown
MemberAuthor

Landed in 2b5f2bc

@BridgeARBridgeAR closed this Dec 3, 2018
BridgeAR added a commit that referenced this pull request Dec 5, 2018
The current internal isError function checked the toString value
instead of using the more precise `util.types.isNativeError()` check.
The `instanceof` check is not removed due to possible errors that
are not native but still an instance of Error.
PR-URL: #24746
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
@BridgeARBridgeAR mentioned this pull request Dec 5, 2018
4 tasks
refack pushed a commit to refack/node that referenced this pull request Jan 14, 2019
The current internal isError function checked the toString value
instead of using the more precise `util.types.isNativeError()` check.
The `instanceof` check is not removed due to possible errors that
are not native but still an instance of Error.
PR-URL: nodejs#24746
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
@BridgeAR
BridgeAR deleted the improve-is-error branch January 20, 2020 11:45
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.utilIssues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@BridgeAR@nodejs-github-bot@sam-github@targos@joyeecheung@devsnek@BethGriggs