From f86fa12debfee4725e534b48ab67ac5b57083f7a Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 16 Sep 2021 17:53:53 +0100 Subject: LibJS: Convert parse_temporal_duration_string() to ThrowCompletionOr --- Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h | 2 +- Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp | 8 ++------ 3 files changed, 4 insertions(+), 8 deletions(-) (limited to 'Userland/Libraries/LibJS') 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 parse_temporal_date_time_string(GlobalObject& glo } // 13.40 ParseTemporalDurationString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaldurationstring -Optional parse_temporal_duration_string(GlobalObject& global_object, String const& iso_string) +ThrowCompletionOr 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 parse_temporal_instant_string(GlobalObject&, ThrowCompletionOr parse_temporal_calendar_string(GlobalObject&, String const& iso_string); ThrowCompletionOr parse_temporal_date_string(GlobalObject&, String const& iso_string); ThrowCompletionOr parse_temporal_date_time_string(GlobalObject&, String const& iso_string); -Optional parse_temporal_duration_string(GlobalObject&, String const& iso_string); +ThrowCompletionOr parse_temporal_duration_string(GlobalObject&, String const& iso_string); Optional parse_temporal_time_string(GlobalObject&, String const& iso_string); Optional parse_temporal_time_zone_string(GlobalObject&, String const& iso_string); Optional 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 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 { -- cgit v1.2.3