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

Make Error a persistent reference #32

Merged
merged 1 commit into from
May 4, 2017
Merged

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