diff options
author | Michael Dawson <michael_dawson@ca.ibm.com> | 2017-06-29 04:53:18 +0300 |
---|---|---|
committer | Michael Dawson <michael_dawson@ca.ibm.com> | 2017-07-13 22:05:19 +0300 |
commit | ac41db4af0443b678adace8d25f5d24935653359 (patch) | |
tree | 4d9f8ab95ee937adf074e9d49b9108a52616cd57 /src/node_api.h | |
parent | 598a128ff46f6ab8d562877f401b32b50366b483 (diff) |
n-api: add code parameter to error helpers
In support of the effort to add error codes to all errors
generated by Node.js, add an optional code parameter to the
helper functions used to throw/create errors in N-API.
PR-URL: https://github.com/nodejs/node/pull/13988
Fixes: https://github.com/nodejs/node/issues/13933
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/node_api.h')
-rw-r--r-- | src/node_api.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/node_api.h b/src/node_api.h index e346b762dd2..af98789d418 100644 --- a/src/node_api.h +++ b/src/node_api.h @@ -142,12 +142,15 @@ NAPI_EXTERN napi_status napi_create_function(napi_env env, void* data, napi_value* result); NAPI_EXTERN napi_status napi_create_error(napi_env env, + napi_value code, napi_value msg, napi_value* result); NAPI_EXTERN napi_status napi_create_type_error(napi_env env, + napi_value code, napi_value msg, napi_value* result); NAPI_EXTERN napi_status napi_create_range_error(napi_env env, + napi_value code, napi_value msg, napi_value* result); @@ -404,9 +407,15 @@ NAPI_EXTERN napi_status napi_escape_handle(napi_env env, // Methods to support error handling NAPI_EXTERN napi_status napi_throw(napi_env env, napi_value error); -NAPI_EXTERN napi_status napi_throw_error(napi_env env, const char* msg); -NAPI_EXTERN napi_status napi_throw_type_error(napi_env env, const char* msg); -NAPI_EXTERN napi_status napi_throw_range_error(napi_env env, const char* msg); +NAPI_EXTERN napi_status napi_throw_error(napi_env env, + const char* code, + const char* msg); +NAPI_EXTERN napi_status napi_throw_type_error(napi_env env, + const char* code, + const char* msg); +NAPI_EXTERN napi_status napi_throw_range_error(napi_env env, + const char* code, + const char* msg); NAPI_EXTERN napi_status napi_is_error(napi_env env, napi_value value, bool* result); |