mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
LibJS: Convert create_non_enum_data_p_or_throw() to ThrowCompletionOr
The actual name is a bit longer, but you know what I mean :^)
This commit is contained in:
parent
364dd42fc8
commit
ebf57df431
5 changed files with 55 additions and 51 deletions
|
@ -48,7 +48,7 @@ Value AggregateErrorConstructor::construct(FunctionObject& new_target)
|
|||
auto message = vm.argument(1).to_string(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
aggregate_error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, message));
|
||||
MUST(aggregate_error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, message)));
|
||||
}
|
||||
|
||||
TRY_OR_DISCARD(aggregate_error->install_error_cause(vm.argument(2)));
|
||||
|
|
|
@ -46,7 +46,7 @@ ThrowCompletionOr<void> Error::install_error_cause(Value options)
|
|||
auto cause = TRY(options.as_object().get(vm.names.cause));
|
||||
|
||||
// b. Perform ! CreateNonEnumerableDataPropertyOrThrow(O, "cause", cause).
|
||||
create_non_enumerable_data_property_or_throw(vm.names.cause, cause);
|
||||
MUST(create_non_enumerable_data_property_or_throw(vm.names.cause, cause));
|
||||
}
|
||||
|
||||
// Return NormalCompletion(undefined).
|
||||
|
|
|
@ -45,7 +45,7 @@ Value ErrorConstructor::construct(FunctionObject& new_target)
|
|||
auto message = vm.argument(0).to_string(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, message));
|
||||
MUST(error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, message)));
|
||||
}
|
||||
|
||||
TRY_OR_DISCARD(error->install_error_cause(vm.argument(1)));
|
||||
|
@ -92,7 +92,7 @@ Value ErrorConstructor::construct(FunctionObject& new_target)
|
|||
auto message = vm.argument(0).to_string(global_object); \
|
||||
if (vm.exception()) \
|
||||
return {}; \
|
||||
error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, message)); \
|
||||
MUST(error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, message))); \
|
||||
} \
|
||||
\
|
||||
TRY_OR_DISCARD(error->install_error_cause(vm.argument(1))); \
|
||||
|
|
|
@ -183,16 +183,20 @@ ThrowCompletionOr<bool> Object::create_data_property_or_throw(PropertyName const
|
|||
}
|
||||
|
||||
// 7.3.6 CreateNonEnumerableDataPropertyOrThrow ( O, P, V ), https://tc39.es/proposal-error-cause/#sec-createnonenumerabledatapropertyorthrow
|
||||
bool Object::create_non_enumerable_data_property_or_throw(PropertyName const& property_name, Value value)
|
||||
ThrowCompletionOr<bool> Object::create_non_enumerable_data_property_or_throw(PropertyName const& property_name, Value value)
|
||||
{
|
||||
VERIFY(!value.is_empty());
|
||||
VERIFY(property_name.is_valid());
|
||||
auto& vm = this->vm();
|
||||
|
||||
// 1. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
auto new_description = PropertyDescriptor { .value = value, .writable = true, .enumerable = false, .configurable = true };
|
||||
|
||||
// 2. Return ? DefinePropertyOrThrow(O, P, newDesc).
|
||||
return define_property_or_throw(property_name, new_description);
|
||||
auto result = define_property_or_throw(property_name, new_description);
|
||||
if (auto* exception = vm.exception())
|
||||
return throw_completion(exception->value());
|
||||
return result;
|
||||
}
|
||||
|
||||
// 7.3.8 DefinePropertyOrThrow ( O, P, desc ), https://tc39.es/ecma262/#sec-definepropertyorthrow
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
ThrowCompletionOr<bool> create_data_property(PropertyName const&, Value);
|
||||
ThrowCompletionOr<bool> create_method_property(PropertyName const&, Value);
|
||||
ThrowCompletionOr<bool> create_data_property_or_throw(PropertyName const&, Value);
|
||||
bool create_non_enumerable_data_property_or_throw(PropertyName const&, Value);
|
||||
ThrowCompletionOr<bool> create_non_enumerable_data_property_or_throw(PropertyName const&, Value);
|
||||
bool define_property_or_throw(PropertyName const&, PropertyDescriptor const&);
|
||||
bool delete_property_or_throw(PropertyName const&);
|
||||
bool has_property(PropertyName const&) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue