napi_create_error


NAPI_EXTERN napi_status napi_create_error(napi_env env,
                                          napi_value code,
                                          napi_value msg,
                                          napi_value* result); 
  • [in] env:调用 API 的环境。

    ¥[in] env: The environment that the API is invoked under.

  • [in] code:可选的 napi_value,带有与错误关联的错误代码的字符串。

    ¥[in] code: Optional napi_value with the string for the error code to be associated with the error.

  • [in] msgnapi_value 引用 JavaScript string 用作 Error 的消息。

    ¥[in] msg: napi_value that references a JavaScript string to be used as the message for the Error.

  • [out] resultnapi_value 表示创建的错误。

    ¥[out] result: napi_value representing the error created.

如果 API 成功,则返回 napi_ok

¥Returns napi_ok if the API succeeded.

此 API 返回带有所提供文本的 JavaScript Error

¥This API returns a JavaScript Error with the text provided.