mirror of
https://github.com/oven-sh/bun
synced 2026-02-18 23:01:58 +00:00
@@ -647,6 +647,24 @@ JSC::EncodedJSValue INVALID_ARG_TYPE(JSC::ThrowScope& throwScope, JSC::JSGlobalO
|
||||
return {};
|
||||
}
|
||||
|
||||
JSC::EncodedJSValue INVALID_ARG_TYPE_INSTANCE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, WTF::ASCIILiteral arg_name, WTF::ASCIILiteral expected_type, WTF::ASCIILiteral expected_instance_types, JSC::JSValue val_actual_value)
|
||||
{
|
||||
JSC::VM& vm = globalObject->vm();
|
||||
WTF::StringBuilder builder;
|
||||
builder.append("The \""_s);
|
||||
builder.append(arg_name);
|
||||
builder.append("\" argument must be of type "_s);
|
||||
builder.append(expected_type);
|
||||
builder.append(" or an instance of "_s);
|
||||
builder.append(expected_instance_types);
|
||||
builder.append(". Received "_s);
|
||||
determineSpecificType(vm, globalObject, builder, val_actual_value);
|
||||
RETURN_IF_EXCEPTION(throwScope, {});
|
||||
|
||||
throwScope.throwException(globalObject, createError(globalObject, ErrorCode::ERR_INVALID_ARG_TYPE, builder.toString()));
|
||||
return {};
|
||||
}
|
||||
|
||||
// When you want INVALID_ARG_TYPE to say "The argument must be an instance of X. Received Y." instead of "The argument must be of type X. Received Y."
|
||||
JSC::EncodedJSValue INVALID_ARG_INSTANCE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::String& arg_name, const WTF::String& expected_type, JSC::JSValue val_actual_value)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user