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

util: improve internal isError() validation #24746

Closed
wants to merge 5 commits into from

Conversation

BridgeAR
Copy link
Member

@BridgeAR BridgeAR commented Nov 30, 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.

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 nodejs-github-bot added the util Issues and PRs related to the built-in util module. label Nov 30, 2018
@BridgeAR
Copy link
Member Author

Copy link
Contributor

@sam-github sam-github left a comment

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.

lib/util.js Show resolved Hide resolved
@BridgeAR
Copy link
Member Author

I just pushed some tests as well.

@BridgeAR
Copy link
Member Author

BridgeAR commented Dec 2, 2018

@nodejs/util PTAL

@BridgeAR
Copy link
Member Author

BridgeAR commented Dec 2, 2018

@BridgeAR BridgeAR 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
Member Author

BridgeAR commented Dec 3, 2018

Landed in 2b5f2bc

@BridgeAR BridgeAR 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>
@BridgeAR BridgeAR 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 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. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants