Skip to content

Commit

Permalink
src: make failure of closing scopes fatal
Browse files Browse the repository at this point in the history
Properly handle failures instead of ignoring them.

PR-URL: #566
Reviewed-By: NickNaso <nicoladelgobbo@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
  • Loading branch information
legendecas authored and mhdawson committed Oct 23, 2019
1 parent 740c798 commit ce139a0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3468,7 +3468,10 @@ inline HandleScope::HandleScope(Napi::Env env) : _env(env) {
}

inline HandleScope::~HandleScope() {
napi_close_handle_scope(_env, _scope);
napi_status status = napi_close_handle_scope(_env, _scope);
NAPI_FATAL_IF_FAILED(status,
"HandleScope::~HandleScope",
"napi_close_handle_scope");
}

inline HandleScope::operator napi_handle_scope() const {
Expand All @@ -3493,7 +3496,10 @@ inline EscapableHandleScope::EscapableHandleScope(Napi::Env env) : _env(env) {
}

inline EscapableHandleScope::~EscapableHandleScope() {
napi_close_escapable_handle_scope(_env, _scope);
napi_status status = napi_close_escapable_handle_scope(_env, _scope);
NAPI_FATAL_IF_FAILED(status,
"EscapableHandleScope::~EscapableHandleScope",
"napi_close_escapable_handle_scope");
}

inline EscapableHandleScope::operator napi_escapable_handle_scope() const {
Expand Down Expand Up @@ -3529,7 +3535,10 @@ inline CallbackScope::CallbackScope(napi_env env, napi_async_context context)
}

inline CallbackScope::~CallbackScope() {
napi_close_callback_scope(_env, _scope);
napi_status status = napi_close_callback_scope(_env, _scope);
NAPI_FATAL_IF_FAILED(status,
"CallbackScope::~CallbackScope",
"napi_close_callback_scope");
}

inline CallbackScope::operator napi_callback_scope() const {
Expand Down

0 comments on commit ce139a0

Please sign in to comment.