From ad793ab93c109ad4918eec168104f796876eb934 Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Sun, 29 Apr 2018 16:49:30 -0400 Subject: [PATCH] n-api: test and doc napi_throw() of a primitive Ensure that napi_throw() is able to throw a primitive value, and document that it is able to throw any JavaScript value. Fixes: https://github.com/nodejs/abi-stable-node/issues/309 PR-URL: https://github.com/nodejs/node/pull/20428 Reviewed-By: Michael Dawson Reviewed-By: Colin Ihrig --- doc/api/n-api.md | 4 ++-- test/addons-napi/test_error/test.js | 12 ++++++++++++ test/addons-napi/test_error/test_error.c | 9 +++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 85993639dc8552..fcbd4decb3538a 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -344,11 +344,11 @@ added: v8.0.0 NODE_EXTERN napi_status napi_throw(napi_env env, napi_value error); ``` - `[in] env`: The environment that the API is invoked under. -- `[in] error`: The `napi_value` for the `Error` to be thrown. +- `[in] error`: The JavaScript value to be thrown. Returns `napi_ok` if the API succeeded. -This API throws the JavaScript `Error` provided. +This API throws the JavaScript value provided. #### napi_throw_error