mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:58:11 +00:00
LibJS: Implement the Error Cause proposal
Currently stage 3. https://github.com/tc39/proposal-error-cause
This commit is contained in:
parent
8d77a3297a
commit
862ba64037
11 changed files with 130 additions and 42 deletions
|
@ -1015,6 +1015,21 @@ Value Object::ordinary_to_primitive(Value::PreferredType preferred_type) const
|
|||
return {};
|
||||
}
|
||||
|
||||
// 20.5.8.1 InstallErrorCause, https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
|
||||
void Object::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);
|
||||
}
|
||||
|
||||
Value Object::invoke_internal(const StringOrSymbol& property_name, Optional<MarkedValueList> arguments)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue