From 091e7aefe27df85aac6e3521505492f459af420c Mon Sep 17 00:00:00 2001 From: legendecas Date: Wed, 16 Oct 2019 00:31:06 +0800 Subject: [PATCH] scopes: make failure of closing scopes fatal But not ignoring these failures. --- napi-inl.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/napi-inl.h b/napi-inl.h index 64315aea6..762b231dc 100644 --- a/napi-inl.h +++ b/napi-inl.h @@ -3472,7 +3472,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 { @@ -3497,7 +3500,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 { @@ -3533,7 +3539,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 {