-
Notifications
You must be signed in to change notification settings - Fork 462
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
don't try to escape null #245
Conversation
If an exception is pending from Call Or MakeCallback on FunctionReference the return value may be nullptr. Check for a pending exception and don't try to escape in these cases.
Might be a dumb question but I thought the general model in node-addon-api is to have script exceptions propagate as C++ exceptions (i.e we'd thrown an exception)- so why doesn't Call or MakeCallback throw if an exception's pending? |
@digitalinfinity I don't quite get your question in the context of this PR. The problem that it addresses is that we invoked Call or MakeCallback and the method that was called threw an exception. |
If you wonder why that did not use C++ node-addon-api supports both using C++ exceptions and not using them. |
Right, I understand that the script method that was called threw an exception- my question was more along the lines of, why not propagate that exception as a C++ exception? I guess your change only applies to the non-exception cases? |
It applies to the default case where the test case was failing. The problem was that it tries to unwrap then it throws a different exception so you get the wrong exception being returned. That would likely be a problem in both cases. |
@digitalinfinity @gabrielschulhof can you review? |
Landed as cf6c93e |
If an exception is pending from Call Or MakeCallback on FunctionReference the return value may be nullptr. Check for a pending exception and don't try to escape in these cases. PR-URL: nodejs/node-addon-api#245 Refs: nodejs/node-addon-api#233 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com>
If an exception is pending from Call Or MakeCallback on FunctionReference the return value may be nullptr. Check for a pending exception and don't try to escape in these cases. PR-URL: nodejs/node-addon-api#245 Refs: nodejs/node-addon-api#233 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com>
If an exception is pending from Call Or MakeCallback on FunctionReference the return value may be nullptr. Check for a pending exception and don't try to escape in these cases. PR-URL: nodejs/node-addon-api#245 Refs: nodejs/node-addon-api#233 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com>
If an exception is pending from Call Or MakeCallback on FunctionReference the return value may be nullptr. Check for a pending exception and don't try to escape in these cases. PR-URL: nodejs/node-addon-api#245 Refs: nodejs/node-addon-api#233 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com>
If an exception is pending from Call Or MakeCallback on
FunctionReference the return value may be nullptr.
Check for a pending exception and don't try to escape in these cases.
Refs: #233
Next step after this would be to add support for throwing fatal exception with node-addon-api which can include a test that validates the exception is correct.