napi_throw_error
NAPI_EXTERN napi_status napi_throw_error(napi_env env,
const char* code,
const char* msg);
-
[in] env
:调用 API 的环境。¥
[in] env
: The environment that the API is invoked under. -
[in] code
:要在错误上设置的可选错误代码。¥
[in] code
: Optional error code to be set on the error. -
[in] msg
:表示与错误关联的文本的 C 字符串。¥
[in] msg
: C string representing the text to be associated with the error.
如果 API 成功,则返回 napi_ok
。
¥Returns napi_ok
if the API succeeded.
此 API 会抛出带有所提供文本的 JavaScript Error
。
¥This API throws a JavaScript Error
with the text provided.