mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +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:
parent
a98201f889
commit
cd526813e6
20 changed files with 340 additions and 364 deletions
|
@ -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 {};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue