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

LibJS: Mark infallible operations that may throw only due to OOM

This commit is contained in:
Timothy Flynn 2023-01-20 14:26:48 -05:00 committed by Linus Groh
parent 52b76060f9
commit 95d1678553
18 changed files with 48 additions and 69 deletions

View file

@ -110,13 +110,12 @@ 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 = TRY(is_structurally_valid_language_tag(vm, code));
auto locale_id = MUST_OR_THROW_OOM(is_structurally_valid_language_tag(vm, code));
if (!locale_id.has_value())
return vm.throw_completion<RangeError>(ErrorType::IntlInvalidLanguageTag, code);
// c. Return ! CanonicalizeUnicodeLocaleId(code).
// NOTE: We TRY this operation only to propagate OOM errors.
auto canonicalized_tag = TRY(canonicalize_unicode_locale_id(vm, *locale_id));
auto canonicalized_tag = MUST_OR_THROW_OOM(canonicalize_unicode_locale_id(vm, *locale_id));
return PrimitiveString::create(vm, move(canonicalized_tag));
}