| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3ac99a2 commit aa47c9f
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -403,12 +403,13 @@ napi_value create_addon(napi_env env); | |||
| 403 | 403 | if (status != napi_ok) { \ | |
| 404 | 404 | const napi_extended_error_info* error_info = NULL; \ | |
| 405 | 405 | napi_get_last_error_info((env), &error_info); \ | |
| 406 | + const char* err_message = error_info->error_message; \ | ||
| 406 | 407 | bool is_pending; \ | |
| 407 | 408 | napi_is_exception_pending((env), &is_pending); \ | |
| 408 | 409 | if (!is_pending) { \ | |
| 409 | - const char* message = (error_info->error_message == NULL) \ | ||
| 410 | + const char* message = (err_message == NULL) \ | ||
| 410 | 411 | ? "empty error message" \ | |
| 411 | - : error_info->error_message; \ | ||
| 412 | + : err_message; \ | ||
| 412 | 413 | napi_throw_error((env), NULL, message); \ | |
| 413 | 414 | return NULL; \ | |
| 414 | 415 | } \ | |
@@ -1005,7 +1006,12 @@ This API retrieves a `napi_extended_error_info` structure with information | |||
| 1005 | 1006 | about the last error that occurred. | |
| 1006 | 1007 | ||
| 1007 | 1008 | The content of the `napi_extended_error_info` returned is only valid up until | |
| 1008 | - a Node-API function is called on the same `env`. | ||
| 1009 | + a Node-API function is called on the same `env`. This includes a call to | ||
| 1010 | + `napi_is_exception_pending` so it may often be necessary to make a copy | ||
| 1011 | + of the information so that it can be used later. The pointer returned | ||
| 1012 | + in error_message points to a statically defined string so it is safe to use | ||
| 1013 | + that pointer if you have copied it out of the error_message field (which will | ||
| 1014 | + be overwritten) before another Node-API function was called. | ||
| 1009 | 1015 | ||
| 1010 | 1016 | Do not rely on the content or format of any of the extended information as it | |
| 1011 | 1017 | is not subject to SemVer and may change at any time. It is intended only for | |
| Back | FazBrowse Home | New Git URL |
0 commit comments