diff options
Diffstat (limited to 'deps/v8/src/objects/js-plural-rules.cc')
-rw-r--r-- | deps/v8/src/objects/js-plural-rules.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/deps/v8/src/objects/js-plural-rules.cc b/deps/v8/src/objects/js-plural-rules.cc index bf928416f4..ffbd53034e 100644 --- a/deps/v8/src/objects/js-plural-rules.cc +++ b/deps/v8/src/objects/js-plural-rules.cc @@ -111,9 +111,14 @@ MaybeHandle<JSPluralRules> JSPluralRules::New(Isolate* isolate, Handle<Map> map, // 11. Let r be ResolveLocale(%PluralRules%.[[AvailableLocales]], // requestedLocales, opt, %PluralRules%.[[RelevantExtensionKeys]], // localeData). - Intl::ResolvedLocale r = + Maybe<Intl::ResolvedLocale> maybe_resolve_locale = Intl::ResolveLocale(isolate, JSPluralRules::GetAvailableLocales(), requested_locales, matcher, {}); + if (maybe_resolve_locale.IsNothing()) { + THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError), + JSPluralRules); + } + Intl::ResolvedLocale r = maybe_resolve_locale.FromJust(); Handle<String> locale_str = isolate->factory()->NewStringFromAsciiChecked(r.locale.c_str()); @@ -124,7 +129,7 @@ MaybeHandle<JSPluralRules> JSPluralRules::New(Isolate* isolate, Handle<Map> map, std::unique_ptr<icu::PluralRules> icu_plural_rules; bool success = CreateICUPluralRules(isolate, r.icu_locale, type, &icu_plural_rules); - if (!success) { + if (!success || icu_plural_rules.get() == nullptr) { // Remove extensions and try again. icu::Locale no_extension_locale(r.icu_locale.getBaseName()); success = CreateICUPluralRules(isolate, no_extension_locale, type, @@ -133,13 +138,12 @@ MaybeHandle<JSPluralRules> JSPluralRules::New(Isolate* isolate, Handle<Map> map, icu::number::NumberFormatter::withLocale(no_extension_locale) .roundingMode(UNUM_ROUND_HALFUP); - if (!success) { - FATAL("Failed to create ICU PluralRules, are ICU data files missing?"); + if (!success || icu_plural_rules.get() == nullptr) { + THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError), + JSPluralRules); } } - CHECK_NOT_NULL(icu_plural_rules.get()); - // 9. Perform ? SetNumberFormatDigitOptions(pluralRules, options, 0, 3). Maybe<Intl::NumberFormatDigitOptions> maybe_digit_options = Intl::SetNumberFormatDigitOptions(isolate, options, 0, 3, false); |