WIP convert napi.cpp functions to set the last error

This commit is contained in:
Ben Grant
2024-10-14 18:40:20 -07:00
parent 6a440aa946
commit ef4728c267
3 changed files with 438 additions and 517 deletions

View File

@@ -52,6 +52,7 @@ class GlobalInternals;
#include "headers-handwritten.h"
#include "BunCommonStrings.h"
#include "BunGlobalScope.h"
#include <js_native_api_types.h>
namespace WebCore {
class WorkerGlobalScope;
@@ -587,6 +588,17 @@ public:
bool hasOverridenModuleResolveFilenameFunction = false;
// Almost all NAPI functions should set error_code to the status they're returning right before
// they return it
napi_extended_error_info m_lastNapiErrorInfo = {
.error_message = "",
// Not currently used by Bun -- always nullptr
.engine_reserved = nullptr,
// Not currently used by Bun -- always zero
.engine_error_code = 0,
.error_code = napi_ok,
};
private:
DOMGuardedObjectSet m_guardedObjects WTF_GUARDED_BY_LOCK(m_gcLock);
WebCore::SubtleCrypto* m_subtleCrypto = nullptr;

File diff suppressed because it is too large Load Diff

View File

@@ -93,12 +93,10 @@ typedef enum {
napi_would_deadlock // unused
} napi_status;
// Note: when adding a new enum value to `napi_status`, please also update
// * `const int last_status` in the definition of `napi_get_last_error_info()'
// in file js_native_api_v8.cc.
// * `const char* error_messages[]` in file js_native_api_v8.cc with a brief
// * `constexpr int last_status` in the definition of `napi_get_last_error_info()'
// in file napi.cpp.
// * `const char* error_messages[]` in file napi.cpp with a brief
// message explaining the error.
// * the definition of `napi_status` in doc/api/n-api.md to reflect the newly
// added value(s).
typedef napi_value (*napi_callback)(napi_env env, napi_callback_info info);
typedef void (*napi_finalize)(napi_env env, void *finalize_data,