1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:37:34 +00:00

LibLocale+LibJS: Make locale data APIs infallible

These APIs only perform small allocations, and are only used by LibJS.
Callers which could only have failed from these APIs are also made to
be infallible here.
This commit is contained in:
Timothy Flynn 2023-08-22 15:39:18 -04:00 committed by Andreas Kling
parent a98201f889
commit cd526813e6
20 changed files with 340 additions and 364 deletions

View file

@ -109,12 +109,12 @@ static ErrorOr<T> find_regional_values_for_locale(StringView locale, GetRegional
auto return_default_values = [&]() { return get_regional_values("001"sv); };
auto language = TRY(parse_unicode_language_id(locale));
auto language = parse_unicode_language_id(locale);
if (!language.has_value())
return return_default_values();
if (!language->region.has_value())
language = TRY(add_likely_subtags(*language));
language = add_likely_subtags(*language);
if (!language.has_value() || !language->region.has_value())
return return_default_values();
@ -253,7 +253,7 @@ static ErrorOr<Optional<String>> format_time_zone_offset(StringView locale, Cale
if (!formats.has_value())
return OptionalNone {};
auto number_system = TRY(get_preferred_keyword_value_for_locale(locale, "nu"sv));
auto number_system = get_preferred_keyword_value_for_locale(locale, "nu"sv);
if (!number_system.has_value())
return OptionalNone {};