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

LibJS: Convert Object::set() to ThrowCompletionOr

This commit is contained in:
Linus Groh 2021-10-03 00:32:43 +01:00
parent b7e5f08e56
commit 1d45541278
18 changed files with 89 additions and 188 deletions

View file

@ -74,9 +74,7 @@ Value ArrayConstructor::construct(FunctionObject& new_target)
return {};
}
}
array->set(vm.names.length, Value(int_length), Object::ShouldThrowExceptions::Yes);
if (vm.exception())
return {};
TRY_OR_DISCARD(array->set(vm.names.length, Value(int_length), Object::ShouldThrowExceptions::Yes));
return array;
}
@ -137,9 +135,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from)
return {};
if (!next) {
array_object.set(vm.names.length, Value(k), Object::ShouldThrowExceptions::Yes);
if (vm.exception())
return {};
TRY_OR_DISCARD(array_object.set(vm.names.length, Value(k), Object::ShouldThrowExceptions::Yes));
return array;
}
@ -198,9 +194,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from)
array_object.create_data_property_or_throw(k, mapped_value);
}
array_object.set(vm.names.length, Value(length), Object::ShouldThrowExceptions::Yes);
if (vm.exception())
return {};
TRY_OR_DISCARD(array_object.set(vm.names.length, Value(length), Object::ShouldThrowExceptions::Yes));
return array;
}
@ -234,9 +228,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::of)
if (vm.exception())
return {};
}
array_object.set(vm.names.length, Value(vm.argument_count()), Object::ShouldThrowExceptions::Yes);
if (vm.exception())
return {};
TRY_OR_DISCARD(array_object.set(vm.names.length, Value(vm.argument_count()), Object::ShouldThrowExceptions::Yes));
return array;
}