Uh oh!
There was an error while loading. Please reload this page.
src: return Maybe<> on pending exception when cpp exception disabled - #927
Conversation
019adad to
2b40b49Compare
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
96baadc to
7d933d0Compare
This comment has been minimized.
This comment has been minimized.
d75115a to
e42a1b9Compareeb8980e to
9684123Comparelegendecas
commented
May 23, 2021
@nodejs/node-api hi, team, I believe this PR is ready and may take some reviews. Thanks a lot! |
Uh oh!
There was an error while loading. Please reload this page.
mhdawson
commented
Jun 10, 2021
A few questions that we might discuss more in the nest team meeting
|
| Value fn(const CallbackInfo& info) { | ||
| Object obj = info[0].As<Object>(); | ||
| Value value = MaybeUnwrap(obj->Get("foobar")); // <- `obj->Get` may throws |
There was a problem hiding this comment.
Should this be in a return or is it that we need to use the helpers for more than returns as well?
| are defined as `Napi::MaybeOrValue<>` to prevent from duplicating most of the | ||
| code base. | ||
| To properly test these build flavors, we should take care of the return value |
There was a problem hiding this comment.
Maybe this should be something like.
To properly test these build flavors, all values returned by a function defined/used within the
node-addon-api test suite, should use one of helpers to ....
| napi_status status = napi_coerce_to_number(_env, _value, &result); | ||
| NAPI_THROW_IF_FAILED(_env, status, Number()); | ||
| return Number(_env, result); | ||
| NAPI_MAYBE_RETURN_OR_THROW_IF_FAILED( |
There was a problem hiding this comment.
I think maybe this should just be called:
NAPI_RETURN_OR_THROW_IF_FAILED
There was a problem hiding this comment.
Sounds much simpler. Renamed.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| } | ||
| inline bool Object::InstanceOf(const Function& constructor) const { | ||
| inline MaybeOrValue<bool> Object::InstanceOf(const Function& constructor) { |
There was a problem hiding this comment.
This should remain const based on our discussion about #992.
There was a problem hiding this comment.
@gabrielschulhof thanks for catching that, not sure why I did not find it on my second look.
There was a problem hiding this comment.
Thanks for catching it, fixed.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
mhdawson
commented
Jun 16, 2021
@legendecas looks like this needs to be rebased. |
# Conflicts: # napi-inl.h # test/binding.gyp
| ```cpp | ||
| #include "napi.h" | ||
| #include "test_helper.h" | ||
| using namespace Napi; | ||
| void fn(const CallbackInfo& info) { | ||
| Object obj = info[0].As<Object>(); | ||
| Value value = MaybeUnwrap(obj->Get("foobar")); // <- `obj->Get` is calling | ||
| // into JavaScript and may throw JavaScript Exceptions. Here we just assert | ||
| // getting the parameter must not fail for convenience. | ||
| // ... do works with the value. | ||
| } | ||
| ``` |
There was a problem hiding this comment.
I think this might be better after the three examples or maybe it could just be removed if we had examples in each of the sections for the helpers?
Uh oh!
There was an error while loading. Please reload this page.
legendecas
commented
Jun 23, 2021
@gabrielschulhof 👋 may I have your review on this again? thanks a lot! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| Napi::Symbol kTestMethodTInternal = Napi::Symbol::New(env, "kTestMethodTInternal"); | ||
| Napi::Symbol kTestVoidMethodTInternal = Napi::Symbol::New(env, "kTestVoidMethodTInternal"); | ||
| exports.Set("Test", DefineClass(env, "Test", { |
There was a problem hiding this comment.
This one and many lines below look like pure whitespace changes. Are they necessary?
There was a problem hiding this comment.
There are two new elements at the bottom of the block. git-clang-format will check with blocks as minimum units.
legendecas
commented
Jul 20, 2021
@gabrielschulhof hi, PR updated with suggestion applied. PTAL, thanks a lot! |
mhdawson
commented
Jul 27, 2021
@gabrielschulhof I'll plan to land end of this week unless you have objections/additional comments before then. |
@mhdawson@gabrielschulhof 👋 should we land this PR now? |
mhdawson
commented
Aug 3, 2021
@legendecas could you squash into 1 commit? I tried landing and I ended up with conflicts. |
legendecas
commented
Aug 3, 2021
@mhdawson used the GitHub interface to squash merging. It seems no conflicts at all.. |
PR-URL: nodejs#927 Reviewed-By: Michael Dawson <midawson@redhat.com>
PR-URL: nodejs#927 Reviewed-By: Michael Dawson <midawson@redhat.com>
PR-URL: nodejs/node-addon-api#927 Reviewed-By: Michael Dawson <midawson@redhat.com>
PR-URL: nodejs/node-addon-api#927 Reviewed-By: Michael Dawson <midawson@redhat.com>
PR-URL: nodejs/node-addon-api#927 Reviewed-By: Michael Dawson <midawson@redhat.com>
PR-URL: nodejs/node-addon-api#927 Reviewed-By: Michael Dawson <midawson@redhat.com>
Fixes: #690
This PR introduced a Maybe type to enforce value existence check when CPP exceptions disabled and there is a pending JavaScript exception so that the operation can not be performed.
The
Maybereturning behavior requires a predefined macroNODE_ADDON_API_ENABLE_MAYBEto enable.