1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:47:45 +00:00

LibJS: Extract exception check duplication in iso_month_day_from_fields

Flagged by sonarcloud.
This commit is contained in:
Brian Gianforcaro 2021-09-12 21:10:49 -07:00 committed by Brian Gianforcaro
parent eb326db028
commit fc1b9288bc

View file

@ -946,16 +946,14 @@ Optional<ISOMonthDay> iso_month_day_from_fields(GlobalObject& global_object, Obj
if (month_code.is_undefined()) {
// a. Let result be ? RegulateISODate(year, month, day, overflow).
result = regulate_iso_date(global_object, year.as_double(), month, day.as_double(), *overflow);
if (vm.exception())
return {};
}
// 13. Else,
else {
// a. Let result be ? RegulateISODate(referenceISOYear, month, day, overflow).
result = regulate_iso_date(global_object, reference_iso_year, month, day.as_double(), *overflow);
if (vm.exception())
return {};
}
if (vm.exception())
return {};
// 14. Return the Record { [[Month]]: result.[[Month]], [[Day]]: result.[[Day]], [[ReferenceISOYear]]: referenceISOYear }.
return ISOMonthDay { .month = result->month, .day = result->day, .reference_iso_year = reference_iso_year };