1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 11:07:35 +00:00

LibJS: Convert to_string() to ThrowCompletionOr

Also update get_function_name() to use ThrowCompletionOr, but this is
not a standard AO and should be refactored out of existence eventually.
This commit is contained in:
Linus Groh 2021-10-12 17:49:01 +01:00
parent 5d38cf4973
commit 4d8912a92b
48 changed files with 171 additions and 415 deletions

View file

@ -187,9 +187,7 @@ ThrowCompletionOr<PlainDateTime*> to_temporal_date_time(GlobalObject& global_obj
(void)TRY(to_temporal_overflow(global_object, *options));
// b. Let string be ? ToString(item).
auto string = item.to_string(global_object);
if (auto* exception = vm.exception())
return throw_completion(exception->value());
auto string = TRY(item.to_string(global_object));
// c. Let result be ? ParseTemporalDateTimeString(string).
result = TRY(parse_temporal_date_time_string(global_object, string));
@ -273,8 +271,6 @@ ThrowCompletionOr<PlainDateTime*> create_temporal_date_time(GlobalObject& global
// 5.5.7 TemporalDateTimeToString ( isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond, calendar, precision, showCalendar ), , https://tc39.es/proposal-temporal/#sec-temporal-temporaldatetimetostring
ThrowCompletionOr<String> temporal_date_time_to_string(GlobalObject& global_object, i32 iso_year, u8 iso_month, u8 iso_day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Value calendar, Variant<StringView, u8> const& precision, StringView show_calendar)
{
auto& vm = global_object.vm();
// 1. Assert: isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, and nanosecond are integers.
// 2. Let year be ! PadISOYear(isoYear).
@ -287,9 +283,7 @@ ThrowCompletionOr<String> temporal_date_time_to_string(GlobalObject& global_obje
auto seconds = format_seconds_string_part(second, millisecond, microsecond, nanosecond, precision);
// 8. Let calendarID be ? ToString(calendar).
auto calendar_id = calendar.to_string(global_object);
if (auto* exception = vm.exception())
return throw_completion(exception->value());
auto calendar_id = TRY(calendar.to_string(global_object));
// 9. Let calendarString be ! FormatCalendarAnnotation(calendarID, showCalendar).
auto calendar_string = format_calendar_annotation(calendar_id, show_calendar);