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

LibJS: Move install_error_cause() from Object to Error

This is only used by Error and its subclasses, so it doesn't need to be
available to all objects.
This commit is contained in:
Linus Groh 2021-06-26 19:06:55 +01:00
parent a63cc2c6b9
commit dbda5a9a4c
4 changed files with 17 additions and 17 deletions

View file

@ -29,6 +29,21 @@ Error::Error(Object& prototype)
{
}
// 20.5.8.1 InstallErrorCause ( O, options ), https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
void Error::install_error_cause(Value options)
{
auto& vm = this->vm();
if (!options.is_object())
return;
auto& options_object = options.as_object();
if (!options_object.has_property(vm.names.cause))
return;
auto cause = options_object.get(vm.names.cause).value_or(js_undefined());
if (vm.exception())
return;
define_property(vm.names.cause, cause, Attribute::Writable | Attribute::Configurable);
}
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
ClassName* ClassName::create(GlobalObject& global_object) \
{ \