1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:47:44 +00:00

LibJS: Propagate OOM errors from Intl Abstract Operations

This excludes the PartitionPattern AO as that has a much larger foot-
print and will be handled separately.
This commit is contained in:
Timothy Flynn 2023-01-19 11:39:05 -05:00 committed by Linus Groh
parent ca62aeb6bd
commit bff0e25ebe
14 changed files with 71 additions and 67 deletions

View file

@ -110,12 +110,13 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(VM& vm, DisplayNames::
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, code, "language"sv);
// b. If IsStructurallyValidLanguageTag(code) is false, throw a RangeError exception.
auto locale_id = is_structurally_valid_language_tag(code);
auto locale_id = TRY(is_structurally_valid_language_tag(vm, code));
if (!locale_id.has_value())
return vm.throw_completion<RangeError>(ErrorType::IntlInvalidLanguageTag, code);
// c. Return ! CanonicalizeUnicodeLocaleId(code).
auto canonicalized_tag = JS::Intl::canonicalize_unicode_locale_id(*locale_id);
// NOTE: We TRY this operation only to propagate OOM errors.
auto canonicalized_tag = TRY(JS::Intl::canonicalize_unicode_locale_id(vm, *locale_id));
return PrimitiveString::create(vm, move(canonicalized_tag));
}