1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:48:11 +00:00

LibJS: Pass prototype to Error constructors

This commit is contained in:
Andreas Kling 2020-04-17 19:31:48 +02:00
parent 0df4d2823a
commit 205ac0090d
5 changed files with 30 additions and 15 deletions

View file

@ -51,7 +51,7 @@ Value ErrorConstructor::construct(Interpreter& interpreter)
String message = "";
if (!interpreter.call_frame().arguments.is_empty() && !interpreter.call_frame().arguments[0].is_undefined())
message = interpreter.call_frame().arguments[0].to_string();
return interpreter.heap().allocate<Error>("Error", message);
return Error::create(interpreter.global_object(), "Error", message);
}
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
@ -70,7 +70,7 @@ Value ErrorConstructor::construct(Interpreter& interpreter)
String message = ""; \
if (!interpreter.call_frame().arguments.is_empty() && !interpreter.call_frame().arguments[0].is_undefined()) \
message = interpreter.call_frame().arguments[0].to_string(); \
return interpreter.heap().allocate<ClassName>(message); \
return ClassName::create(interpreter.global_object(), message); \
}
JS_ENUMERATE_ERROR_SUBCLASSES