diff options
author | Linus Groh <mail@linusgroh.de> | 2021-06-26 19:06:55 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-06-26 19:06:55 +0100 |
commit | dbda5a9a4ccfa3ab8e2e913800559f95dde48291 (patch) | |
tree | 1316ec688c01965d6113dfa117a2ba06efe323f1 /Userland/Libraries/LibJS/Runtime/Error.cpp | |
parent | a63cc2c6b9e6b0508b92796c631abcfd584ddd68 (diff) | |
download | serenity-dbda5a9a4ccfa3ab8e2e913800559f95dde48291.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Error.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Error.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Error.cpp b/Userland/Libraries/LibJS/Runtime/Error.cpp index c2fb594ce5..8eddcc68b8 100644 --- a/Userland/Libraries/LibJS/Runtime/Error.cpp +++ b/Userland/Libraries/LibJS/Runtime/Error.cpp @@ -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) \ { \ |