napi_get_last_error_info
napi_status
napi_get_last_error_info(node_api_basic_env env,
const napi_extended_error_info** result);
-
[in] env
:调用 API 的环境。¥
[in] env
: The environment that the API is invoked under. -
[out] result
:包含有关错误的更多信息的napi_extended_error_info
结构。¥
[out] result
: Thenapi_extended_error_info
structure with more information about the error.
如果 API 成功,则返回 napi_ok
。
¥Returns napi_ok
if the API succeeded.
此 API 检索 napi_extended_error_info
结构,其中包含有关发生的最后一个错误的信息。
¥This API retrieves a napi_extended_error_info
structure with information
about the last error that occurred.
返回的 napi_extended_error_info
的内容仅在对同一 env
调用 Node-API 函数之前有效。这包括对 napi_is_exception_pending
的调用,因此可能经常需要复制信息以便以后使用。error_message
中返回的指针指向一个静态定义的字符串,因此如果你在调用另一个 Node-API 函数之前将它从 error_message
字段(将被覆盖)中复制出来,则可以安全地使用该指针。
¥The content of the napi_extended_error_info
returned is only valid up until
a Node-API function is called on the same env
. This includes a call to
napi_is_exception_pending
so it may often be necessary to make a copy
of the information so that it can be used later. The pointer returned
in error_message
points to a statically-defined string so it is safe to use
that pointer if you have copied it out of the error_message
field (which will
be overwritten) before another Node-API function was called.
不要依赖任何扩展信息的内容或格式,因为它不受 SemVer 的约束并且可能随时更改。它仅用于记录目的。
¥Do not rely on the content or format of any of the extended information as it is not subject to SemVer and may change at any time. It is intended only for logging purposes.
即使存在挂起的 JavaScript 异常,也可以调用此 API。
¥This API can be called even if there is a pending JavaScript exception.