This commit is contained in:
Jarred Sumner
2024-09-01 22:40:31 -07:00
committed by GitHub
parent 5f6015bb79
commit b64f1e15b5
16 changed files with 232 additions and 116 deletions

View File

@@ -1,6 +1,7 @@
#include "root.h"
#include "ZigGlobalObject.h"
#include "DOMException.h"
#include "JavaScriptCore/Error.h"
#include "JavaScriptCore/ErrorType.h"
@@ -27,8 +28,6 @@
#include "ErrorCode.h"
extern "C" Zig::GlobalObject* Bun__getDefaultGlobalObject();
static JSC::JSObject* createErrorPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::ErrorType type, WTF::ASCIILiteral name, WTF::ASCIILiteral code, bool isDOMExceptionPrototype = false)
{
JSC::JSObject* prototype;
@@ -36,11 +35,7 @@ static JSC::JSObject* createErrorPrototype(JSC::VM& vm, JSC::JSGlobalObject* glo
// Inherit from DOMException
// But preserve the error.stack property.
if (isDOMExceptionPrototype) {
auto* domGlobalObject = JSC::jsDynamicCast<Zig::GlobalObject*>(globalObject);
if (UNLIKELY(!domGlobalObject)) {
domGlobalObject = Bun__getDefaultGlobalObject();
}
// TODO: node:vm?
auto* domGlobalObject = defaultGlobalObject(globalObject);
prototype = JSC::constructEmptyObject(globalObject, WebCore::JSDOMException::prototype(vm, *domGlobalObject));
} else {
switch (type) {