n-api: factor out calling pattern

Factor out how we handle a `napi_status`-valued return internally.

Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: https://github.com/nodejs/node/pull/36113
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Gabriel Schulhof
2020-11-13 13:07:36 -08:00
parent 187ce5bd06
commit 2fd22353ea
3 changed files with 21 additions and 38 deletions

View File

@@ -1130,11 +1130,8 @@ napi_status napi_queue_async_work(napi_env env, napi_async_work work) {
CHECK_ENV(env);
CHECK_ARG(env, work);
napi_status status;
uv_loop_t* event_loop = nullptr;
status = napi_get_uv_event_loop(env, &event_loop);
if (status != napi_ok)
return napi_set_last_error(env, status);
STATUS_CALL(napi_get_uv_event_loop(env, &event_loop));
uvimpl::Work* w = reinterpret_cast<uvimpl::Work*>(work);