mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-24 02:09:28 +00:00
LibJS: Consolidate error messages into ErrorTypes.h
Now, exceptions can be thrown with interpreter.throw_exception<T>(ErrorType:TYPE, "format", "args", "here").
This commit is contained in:
committed by
Andreas Kling
parent
9940a7f6de
commit
78155a6668
@@ -46,21 +46,21 @@ ProxyConstructor::~ProxyConstructor()
|
||||
|
||||
Value ProxyConstructor::call(Interpreter& interpreter)
|
||||
{
|
||||
return interpreter.throw_exception<TypeError>("Proxy must be called with the \"new\" operator");
|
||||
return interpreter.throw_exception<TypeError>(ErrorType::ProxyCallWithNew);
|
||||
}
|
||||
|
||||
Value ProxyConstructor::construct(Interpreter& interpreter)
|
||||
{
|
||||
if (interpreter.argument_count() < 2)
|
||||
return interpreter.throw_exception<TypeError>("Proxy requires at least two arguments");
|
||||
return interpreter.throw_exception<TypeError>(ErrorType::ProxyTwoArguments);
|
||||
|
||||
auto target = interpreter.argument(0);
|
||||
auto handler = interpreter.argument(1);
|
||||
|
||||
if (!target.is_object())
|
||||
return interpreter.throw_exception<TypeError>(String::format("Expected target argument of Proxy constructor to be object, got %s", target.to_string_without_side_effects().characters()));
|
||||
return interpreter.throw_exception<TypeError>(ErrorType::ProxyConstructorBadType, "target", target.to_string_without_side_effects().characters());
|
||||
if (!handler.is_object())
|
||||
return interpreter.throw_exception<TypeError>(String::format("Expected handler argument of Proxy constructor to be object, got %s", handler.to_string_without_side_effects().characters()));
|
||||
return interpreter.throw_exception<TypeError>(ErrorType::ProxyConstructorBadType, "handler", handler.to_string_without_side_effects().characters());
|
||||
|
||||
return ProxyObject::create(global_object(), target.as_object(), handler.as_object());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user