1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 10:37:45 +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

@ -84,9 +84,7 @@ ThrowCompletionOr<PlainTime*> to_temporal_time(GlobalObject& global_object, Valu
auto* calendar = TRY(get_temporal_calendar_with_iso_default(global_object, item_object));
// e. If ? ToString(calendar) is not "iso8601", then
auto calendar_identifier = Value(calendar).to_string(global_object);
if (auto* exception = vm.exception())
return throw_completion(exception->value());
auto calendar_identifier = TRY(Value(calendar).to_string(global_object));
if (calendar_identifier != "iso8601"sv) {
// i. Throw a RangeError exception.
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarIdentifier, calendar_identifier);
@ -101,9 +99,7 @@ ThrowCompletionOr<PlainTime*> to_temporal_time(GlobalObject& global_object, Valu
// 4. Else,
else {
// a. 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));
// b. Let result be ? ParseTemporalTimeString(string).
result = TRY(parse_temporal_time_string(global_object, string));