1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:37:44 +00:00

LibJS: Convert to_integer_throw_on_infinity() to ThrowCompletionOr

This commit is contained in:
Linus Groh 2021-09-15 23:03:38 +01:00
parent fea27143e9
commit 683e31e1ff
10 changed files with 46 additions and 125 deletions

View file

@ -1087,9 +1087,7 @@ double to_positive_integer(GlobalObject& global_object, Value argument)
auto& vm = global_object.vm();
// 1. Let integer be ? ToIntegerThrowOnInfinity(argument).
auto integer = to_integer_throw_on_infinity(global_object, argument, ErrorType::TemporalPropertyMustBePositiveInteger);
if (vm.exception())
return {};
auto integer = TRY_OR_DISCARD(to_integer_throw_on_infinity(global_object, argument, ErrorType::TemporalPropertyMustBePositiveInteger));
// 2. If integer ≤ 0, then
if (integer <= 0) {
@ -1141,9 +1139,7 @@ Object* prepare_temporal_fields(GlobalObject& global_object, Object const& field
// 1. Let Conversion represent the abstract operation named by the Conversion value of the same row.
// 2. Set value to ? Conversion(value).
if (property.is_one_of("year", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "eraYear")) {
value = Value(to_integer_throw_on_infinity(global_object, value, ErrorType::TemporalPropertyMustBeFinite));
if (vm.exception())
return {};
value = Value(TRY_OR_DISCARD(to_integer_throw_on_infinity(global_object, value, ErrorType::TemporalPropertyMustBeFinite)));
} else if (property.is_one_of("month", "day")) {
value = Value(to_positive_integer(global_object, value));
if (vm.exception())