summaryrefslogtreecommitdiff
path: root/src/js_native_api_v8.cc
diff options
context:
space:
mode:
authorOctavian Soldea <octavian.soldea@intel.com>2019-07-11 16:23:12 -0700
committerGabriel Schulhof <gabriel.schulhof@intel.com>2019-07-17 12:11:36 -0700
commitda69f56e7f317651949bc2305513a005ae837ed0 (patch)
tree4c67e6f912bd1024c1133716bc63b77b068f7492 /src/js_native_api_v8.cc
parent54fcb14467b59e82d6e24bf44803462226a5de4d (diff)
downloadandroid-node-v8-da69f56e7f317651949bc2305513a005ae837ed0.tar.gz
android-node-v8-da69f56e7f317651949bc2305513a005ae837ed0.tar.bz2
android-node-v8-da69f56e7f317651949bc2305513a005ae837ed0.zip
n-api: correct bug in napi_get_last_error
napi_get_last_error returns incorrect napi_status. PR-URL: https://github.com/nodejs/node/pull/28702 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'src/js_native_api_v8.cc')
-rw-r--r--src/js_native_api_v8.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc
index 2f5a4bf83c..5dac55cc82 100644
--- a/src/js_native_api_v8.cc
+++ b/src/js_native_api_v8.cc
@@ -684,14 +684,16 @@ napi_status napi_get_last_error_info(napi_env env,
CHECK_ENV(env);
CHECK_ARG(env, result);
- // you must update this assert to reference the last message
- // in the napi_status enum each time a new error message is added.
+ // The value of the constant below must be updated to reference the last
+ // message in the `napi_status` enum each time a new error message is added.
// We don't have a napi_status_last as this would result in an ABI
// change each time a message was added.
+ const int last_status = napi_date_expected;
+
static_assert(
- NAPI_ARRAYSIZE(error_messages) == napi_date_expected + 1,
+ NAPI_ARRAYSIZE(error_messages) == last_status + 1,
"Count of error messages must match count of error values");
- CHECK_LE(env->last_error.error_code, napi_callback_scope_mismatch);
+ CHECK_LE(env->last_error.error_code, last_status);
// Wait until someone requests the last error information to fetch the error
// message string