-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Conversation
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.
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 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.
I just pushed some tests as well. |
@nodejs/util PTAL |
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>
Landed in 2b5f2bc |
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>
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>
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 thatare not native but still an instance of Error.
The internal
isError
function is only used inutil.inspect()
and therepl
.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes