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

src: expose V8's IsNativeError() in util bindings #12546

Merged
merged 1 commit into from
Apr 25, 2017

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Apr 20, 2017

Exposes IsNativeError() through process.binding('util'). The tests are copied from util.isError(). The results are the same with the exception of the last one (object inheriting from Error).

R= @addaleax because of #12400 (comment)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

src

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. util Issues and PRs related to the built-in util module. labels Apr 20, 2017
@cjihrig cjihrig requested a review from addaleax April 20, 2017 17:53
Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

LGTM, but I’d say you can feel free to pick this into your other PR if you like

@cjihrig
Copy link
Contributor Author

cjihrig commented Apr 25, 2017

assert.strictEqual(binding.isNativeError(new TypeError()), true);
assert.strictEqual(binding.isNativeError(new SyntaxError()), true);
/* eslint-disable new-parens */
assert.strictEqual(binding.isNativeError(new (context('Error'))), true);
Copy link
Member

Choose a reason for hiding this comment

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

new (context('Error'))()

I think that should fulfill the "new-parens" ESLint rule as well.

Refs: nodejs#12400
PR-URL: nodejs#12546
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@cjihrig cjihrig merged commit e522bcd into nodejs:master Apr 25, 2017
@cjihrig cjihrig deleted the is-native-error branch April 25, 2017 16:47
@cjihrig
Copy link
Contributor Author

cjihrig commented Apr 25, 2017

Landed with @TimothyGu's suggestion.

evanlucas pushed a commit that referenced this pull request Apr 25, 2017
Refs: #12400
PR-URL: #12546
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@evanlucas evanlucas mentioned this pull request May 1, 2017
evanlucas pushed a commit that referenced this pull request May 1, 2017
Refs: #12400
PR-URL: #12546
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
evanlucas pushed a commit that referenced this pull request May 2, 2017
Refs: #12400
PR-URL: #12546
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@gibfahn
Copy link
Member

gibfahn commented May 16, 2017

I get this error when backporting this to v6.x, which I assume means that this shouldn't land. LMK if that's not the case.

=== release test-util ===                    
Path: parallel/test-util
testtest
DEBUG: test
test

assert.js:81
  throw new assert.AssertionError({
  ^
AssertionError: false === true

@addaleax
Copy link
Member

Fwiw the v8 patch that would fix that failure is v8/v8@a2dad04, I think.

@gibfahn
Copy link
Member

gibfahn commented May 17, 2017

If this is something that's worth landing on Node 6, then a backport PR with e522bcd and v8/v8@a2dad04 would be welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. 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