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

LibJS: Convert Object::get() to ThrowCompletionOr

To no one's surprise, this patch is pretty big - this is possibly the
most used AO of all of them. Definitely worth it though.
This commit is contained in:
Linus Groh 2021-10-02 23:52:27 +01:00
parent 9b6c09e2c4
commit b7e5f08e56
61 changed files with 326 additions and 686 deletions

View file

@ -245,12 +245,14 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::from_entries)
vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
return IterationDecision::Break;
}
auto key = iterator_value.as_object().get(0);
if (vm.exception())
auto key_or_error = iterator_value.as_object().get(0);
if (key_or_error.is_error())
return IterationDecision::Break;
auto value = iterator_value.as_object().get(1);
if (vm.exception())
auto key = key_or_error.release_value();
auto value_or_error = iterator_value.as_object().get(1);
if (value_or_error.is_error())
return IterationDecision::Break;
auto value = value_or_error.release_value();
auto property_key = key.to_property_key(global_object);
if (vm.exception())
return IterationDecision::Break;
@ -484,9 +486,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::assign)
continue;
// a. Let propValue be ? Get(from, nextKey).
auto prop_value = from->get(property_name);
if (vm.exception())
return {};
auto prop_value = TRY_OR_DISCARD(from->get(property_name));
// b. Perform ? Set(to, nextKey, propValue, true).
to->set(property_name, prop_value, Object::ShouldThrowExceptions::Yes);