diff options
author | Linus Groh <mail@linusgroh.de> | 2021-09-16 17:54:42 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-09-16 22:34:24 +0100 |
commit | 0ccd11ba5f292a62eb8eb41a510207cc1da75a56 (patch) | |
tree | a8127278b0cab557321f114670c1ddb67440cec0 /Userland/Libraries/LibJS | |
parent | f86fa12debfee4725e534b48ab67ac5b57083f7a (diff) | |
download | serenity-0ccd11ba5f292a62eb8eb41a510207cc1da75a56.zip |
LibJS: Convert parse_temporal_time_string() to ThrowCompletionOr
Diffstat (limited to 'Userland/Libraries/LibJS')
3 files changed, 4 insertions, 6 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index 16fda0ea23..59e0a90e7c 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -900,7 +900,7 @@ ThrowCompletionOr<TemporalDuration> parse_temporal_duration_string(GlobalObject& } // 13.43 ParseTemporalTimeString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaltimestring -Optional<TemporalTime> parse_temporal_time_string(GlobalObject& global_object, [[maybe_unused]] String const& iso_string) +ThrowCompletionOr<TemporalTime> parse_temporal_time_string(GlobalObject& global_object, [[maybe_unused]] String const& iso_string) { // 1. Assert: Type(isoString) is String. @@ -909,7 +909,7 @@ Optional<TemporalTime> parse_temporal_time_string(GlobalObject& global_object, [ // TODO // 3. Let result be ? ParseISODateTime(isoString). - auto result = TRY_OR_DISCARD(parse_iso_date_time(global_object, iso_string)); + auto result = TRY(parse_iso_date_time(global_object, iso_string)); // 4. Return the Record { [[Hour]]: result.[[Hour]], [[Minute]]: result.[[Minute]], [[Second]]: result.[[Second]], [[Millisecond]]: result.[[Millisecond]], [[Microsecond]]: result.[[Microsecond]], [[Nanosecond]]: result.[[Nanosecond]], [[Calendar]]: result.[[Calendar]] }. return TemporalTime { .hour = result.hour, .minute = result.minute, .second = result.second, .millisecond = result.millisecond, .microsecond = result.microsecond, .nanosecond = result.nanosecond, .calendar = move(result.calendar) }; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h index 860035fa5c..dc7e4b274f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h @@ -109,7 +109,7 @@ ThrowCompletionOr<String> parse_temporal_calendar_string(GlobalObject&, String c ThrowCompletionOr<TemporalDate> parse_temporal_date_string(GlobalObject&, String const& iso_string); ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(GlobalObject&, String const& iso_string); ThrowCompletionOr<TemporalDuration> parse_temporal_duration_string(GlobalObject&, String const& iso_string); -Optional<TemporalTime> parse_temporal_time_string(GlobalObject&, String const& iso_string); +ThrowCompletionOr<TemporalTime> parse_temporal_time_string(GlobalObject&, String const& iso_string); Optional<TemporalTimeZone> parse_temporal_time_zone_string(GlobalObject&, String const& iso_string); Optional<TemporalYearMonth> parse_temporal_year_month_string(GlobalObject&, String const& iso_string); double to_positive_integer(GlobalObject&, Value argument); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp index 9fbc90bd53..37140968f0 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp @@ -108,9 +108,7 @@ ThrowCompletionOr<PlainTime*> to_temporal_time(GlobalObject& global_object, Valu return throw_completion(exception->value()); // b. Let result be ? ParseTemporalTimeString(string). - result = parse_temporal_time_string(global_object, string); - if (auto* exception = vm.exception()) - return throw_completion(exception->value()); + result = TRY(parse_temporal_time_string(global_object, string)); // c. Assert: ! IsValidTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]) is true. VERIFY(is_valid_time(result->hour, result->minute, result->second, result->millisecond, result->microsecond, result->nanosecond)); |