mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:57:35 +00:00
LibJS: Add VM::throw_completion helper for throwing custom Strings
This commit is contained in:
parent
f302b114f3
commit
e24d4c346d
1 changed files with 8 additions and 2 deletions
|
@ -234,14 +234,20 @@ public:
|
|||
|
||||
// 5.2.3.2 Throw an Exception, https://tc39.es/ecma262/#sec-throw-an-exception
|
||||
template<typename T, typename... Args>
|
||||
Completion throw_completion(GlobalObject& global_object, ErrorType type, Args&&... args)
|
||||
Completion throw_completion(GlobalObject& global_object, Args&&... args)
|
||||
{
|
||||
auto* error = T::create(global_object, String::formatted(type.message(), forward<Args>(args)...));
|
||||
auto* error = T::create(global_object, forward<Args>(args)...);
|
||||
// NOTE: This is temporary until we remove VM::exception().
|
||||
throw_exception(global_object, error);
|
||||
return JS::throw_completion(error);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
Completion throw_completion(GlobalObject& global_object, ErrorType type, Args&&... args)
|
||||
{
|
||||
return throw_completion<T>(global_object, String::formatted(type.message(), forward<Args>(args)...));
|
||||
}
|
||||
|
||||
Value construct(FunctionObject&, FunctionObject& new_target, Optional<MarkedValueList> arguments);
|
||||
|
||||
String join_arguments(size_t start_index = 0) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue