mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 03:18:53 +00:00
@@ -360,3 +360,14 @@ extern "C" JSC::EncodedJSValue WebCore__CommonAbortReason__toJS(JSC::JSGlobalObj
|
||||
{
|
||||
return JSC::JSValue::encode(WebCore::toJS(globalObject, abortReason));
|
||||
}
|
||||
|
||||
JSC::JSObject* Bun::createInvalidThisError(JSC::JSGlobalObject* globalObject, JSC::JSValue thisValue, const ASCIILiteral typeName)
|
||||
{
|
||||
if (thisValue.isEmpty() || thisValue.isUndefined()) {
|
||||
return Bun::createError(globalObject, Bun::ErrorCode::ERR_INVALID_THIS, makeString("Expected this to be instanceof "_s, typeName));
|
||||
}
|
||||
|
||||
// Pathological case: the this value returns a string which is extremely long or causes an out of memory error.
|
||||
const auto& typeString = thisValue.isString() ? String("a string"_s) : JSC::errorDescriptionForValue(globalObject, thisValue);
|
||||
return Bun::createError(globalObject, Bun::ErrorCode::ERR_INVALID_THIS, makeString("Expected this to be instanceof "_s, typeName, ", but received "_s, typeString));
|
||||
}
|
||||
Reference in New Issue
Block a user