mirror of
https://github.com/oven-sh/bun
synced 2026-02-18 23:01:58 +00:00
mime api (test-mime-api, test-mime-whatwg) (#19284)
This commit is contained in:
@@ -1384,6 +1384,24 @@ JSC::EncodedJSValue MISSING_OPTION(JSC::ThrowScope& scope, JSC::JSGlobalObject*
|
||||
return {};
|
||||
}
|
||||
|
||||
JSC::EncodedJSValue INVALID_MIME_SYNTAX(JSC::ThrowScope& scope, JSC::JSGlobalObject* globalObject, const String& part, const String& input, int position)
|
||||
{
|
||||
WTF::StringBuilder builder;
|
||||
builder.append("The MIME syntax for a "_s);
|
||||
builder.append(part);
|
||||
builder.append(" in "_s);
|
||||
builder.append(input);
|
||||
|
||||
builder.append(" is invalid"_s);
|
||||
if (position != -1) {
|
||||
builder.append(" at "_s);
|
||||
builder.append(String::number(position));
|
||||
}
|
||||
|
||||
scope.throwException(globalObject, createError(globalObject, ErrorCode::ERR_INVALID_MIME_SYNTAX, builder.toString()));
|
||||
return {};
|
||||
}
|
||||
|
||||
EncodedJSValue CLOSED_MESSAGE_PORT(ThrowScope& scope, JSGlobalObject* globalObject)
|
||||
{
|
||||
scope.throwException(globalObject, createError(globalObject, ErrorCode::ERR_CLOSED_MESSAGE_PORT, "Cannot send data on closed MessagePort"_s));
|
||||
@@ -1606,6 +1624,19 @@ JSC_DEFINE_HOST_FUNCTION(Bun::jsFunctionMakeErrorWithCode, (JSC::JSGlobalObject
|
||||
return JSValue::encode(createError(globalObject, ErrorCode::ERR_INVALID_IP_ADDRESS, builder.toString()));
|
||||
}
|
||||
|
||||
case Bun::ErrorCode::ERR_INVALID_MIME_SYNTAX: {
|
||||
auto arg0 = callFrame->argument(1);
|
||||
auto str0 = arg0.toWTFString(globalObject);
|
||||
RETURN_IF_EXCEPTION(scope, {});
|
||||
auto arg1 = callFrame->argument(2);
|
||||
auto str1 = arg1.toWTFString(globalObject);
|
||||
RETURN_IF_EXCEPTION(scope, {});
|
||||
auto arg2 = callFrame->argument(3);
|
||||
auto str2 = arg2.toInt32(globalObject);
|
||||
RETURN_IF_EXCEPTION(scope, {});
|
||||
return ERR::INVALID_MIME_SYNTAX(scope, globalObject, str0, str1, str2);
|
||||
}
|
||||
|
||||
case Bun::ErrorCode::ERR_INVALID_ADDRESS_FAMILY: {
|
||||
auto arg0 = callFrame->argument(1);
|
||||
auto str0 = arg0.toWTFString(globalObject);
|
||||
|
||||
Reference in New Issue
Block a user