Skip to content

Conversation

jasongin
Copy link
Member

@jasongin jasongin commented May 1, 2017

A Napi::Error instance must hold a persistent reference to the JS error object so that it can escape from handle scopes when thrown as a C++ exception.

Fixes: #31

A Napi::Error instance must hold a persistent reference to the JS
error object so that it can escape from handle scopes when thrown
as a C++ exception.

Fixes: nodejs#31
@jasongin jasongin mentioned this pull request May 1, 2017
Copy link

@boingoing boingoing left a comment

Choose a reason for hiding this comment

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

LGTM, just one question about the case where we encounter a failure to create a ref for the JavaScript error in the Error ctor.


// Avoid infinite recursion in the failure case.
// Don't try to construct & throw another Error instance.
assert(status == napi_ok);

Choose a reason for hiding this comment

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

Should we cause a fatal error here to kill the process?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably. See also a few other places in this Error class where error-handling code can't throw errors.

We'd need a napi_fatal_error() API or similar.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll leave this the way it is for now. Fatal error discussion is at nodejs/abi-stable-node#232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants