diff options
author | Linus Groh <mail@linusgroh.de> | 2021-09-16 17:53:53 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-09-16 22:34:24 +0100 |
commit | f86fa12debfee4725e534b48ab67ac5b57083f7a (patch) | |
tree | 90eaea57f01cb8638139922139d560b35324504d /Userland/Libraries | |
parent | 3c530dec5aebb5ef50a958f5f85f8ec8176c415c (diff) | |
download | serenity-f86fa12debfee4725e534b48ab67ac5b57083f7a.zip |
LibJS: Convert parse_temporal_duration_string() to ThrowCompletionOr
Diffstat (limited to 'Userland/Libraries')
3 files changed, 4 insertions, 8 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index 26ddd60b17..16fda0ea23 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -892,7 +892,7 @@ ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(GlobalObject& glo } // 13.40 ParseTemporalDurationString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaldurationstring -Optional<TemporalDuration> parse_temporal_duration_string(GlobalObject& global_object, String const& iso_string) +ThrowCompletionOr<TemporalDuration> parse_temporal_duration_string(GlobalObject& global_object, String const& iso_string) { (void)global_object; (void)iso_string; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h index 6076bad97d..860035fa5c 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h @@ -108,7 +108,7 @@ ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(GlobalObject&, ThrowCompletionOr<String> parse_temporal_calendar_string(GlobalObject&, String const& iso_string); ThrowCompletionOr<TemporalDate> parse_temporal_date_string(GlobalObject&, String const& iso_string); ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(GlobalObject&, String const& iso_string); -Optional<TemporalDuration> parse_temporal_duration_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); Optional<TemporalTimeZone> parse_temporal_time_zone_string(GlobalObject&, String const& iso_string); Optional<TemporalYearMonth> parse_temporal_year_month_string(GlobalObject&, String const& iso_string); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp index 1b93b0007e..05158486a0 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp @@ -57,9 +57,7 @@ Duration* to_temporal_duration(GlobalObject& global_object, Value item) return {}; // b. Let result be ? ParseTemporalDurationString(string). - result = parse_temporal_duration_string(global_object, string); - if (vm.exception()) - return {}; + result = TRY_OR_DISCARD(parse_temporal_duration_string(global_object, string)); } // 3. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]). @@ -469,9 +467,7 @@ Optional<TemporalDuration> to_limited_temporal_duration(GlobalObject& global_obj return {}; // b. Let duration be ? ParseTemporalDurationString(str). - duration = parse_temporal_duration_string(global_object, str); - if (vm.exception()) - return {}; + duration = TRY_OR_DISCARD(parse_temporal_duration_string(global_object, str)); } // 2. Else, else { |