Commit 6f112a08 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

Replace FATAL with exception throw in Intl objects

Bug: v8:10224
Change-Id: I852d3b1e3468086b36e357aceeb0167951205bcc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2067695
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66394}
parent 6b08f2e6
...@@ -84,10 +84,10 @@ MaybeHandle<JSV8BreakIterator> JSV8BreakIterator::New( ...@@ -84,10 +84,10 @@ MaybeHandle<JSV8BreakIterator> JSV8BreakIterator::New(
} }
// Error handling for break_iterator // Error handling for break_iterator
if (U_FAILURE(status)) { if (U_FAILURE(status) || break_iterator.get() == nullptr) {
FATAL("Failed to create ICU break iterator, are ICU data files missing?"); THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),
JSV8BreakIterator);
} }
CHECK_NOT_NULL(break_iterator.get());
isolate->CountUsage(v8::Isolate::UseCounterFeature::kBreakIterator); isolate->CountUsage(v8::Isolate::UseCounterFeature::kBreakIterator);
// Construct managed objects from pointers // Construct managed objects from pointers
......
...@@ -364,11 +364,11 @@ MaybeHandle<JSCollator> JSCollator::New(Isolate* isolate, Handle<Map> map, ...@@ -364,11 +364,11 @@ MaybeHandle<JSCollator> JSCollator::New(Isolate* isolate, Handle<Map> map,
icu::Collator::createInstance(no_extension_locale, status)); icu::Collator::createInstance(no_extension_locale, status));
if (U_FAILURE(status) || icu_collator.get() == nullptr) { if (U_FAILURE(status) || icu_collator.get() == nullptr) {
FATAL("Failed to create ICU collator, are ICU data files missing?"); THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),
JSCollator);
} }
} }
DCHECK(U_SUCCESS(status)); DCHECK(U_SUCCESS(status));
CHECK_NOT_NULL(icu_collator.get());
// 22. If relevantExtensionKeys contains "kn", then // 22. If relevantExtensionKeys contains "kn", then
// a. Set collator.[[Numeric]] to ! SameValue(r.[[kn]], "true"). // a. Set collator.[[Numeric]] to ! SameValue(r.[[kn]], "true").
......
...@@ -1583,7 +1583,8 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New( ...@@ -1583,7 +1583,8 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
icu_date_format = CreateICUDateFormatFromCache(icu_locale, skeleton_ustr, icu_date_format = CreateICUDateFormatFromCache(icu_locale, skeleton_ustr,
generator.get(), hc); generator.get(), hc);
if (icu_date_format.get() == nullptr) { if (icu_date_format.get() == nullptr) {
FATAL("Failed to create ICU date format, are ICU data files missing?"); THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),
JSDateTimeFormat);
} }
} }
......
...@@ -171,11 +171,11 @@ MaybeHandle<JSListFormat> JSListFormat::New(Isolate* isolate, Handle<Map> map, ...@@ -171,11 +171,11 @@ MaybeHandle<JSListFormat> JSListFormat::New(Isolate* isolate, Handle<Map> map,
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
icu::ListFormatter* formatter = icu::ListFormatter::createInstance( icu::ListFormatter* formatter = icu::ListFormatter::createInstance(
icu_locale, GetIcuStyleString(style_enum, type_enum), status); icu_locale, GetIcuStyleString(style_enum, type_enum), status);
if (U_FAILURE(status)) { if (U_FAILURE(status) || formatter == nullptr) {
delete formatter; delete formatter;
FATAL("Failed to create ICU list formatter, are ICU data files missing?"); THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),
JSListFormat);
} }
CHECK_NOT_NULL(formatter);
Handle<Managed<icu::ListFormatter>> managed_formatter = Handle<Managed<icu::ListFormatter>> managed_formatter =
Managed<icu::ListFormatter>::FromRawPtr(isolate, 0, formatter); Managed<icu::ListFormatter>::FromRawPtr(isolate, 0, formatter);
......
...@@ -124,7 +124,7 @@ MaybeHandle<JSPluralRules> JSPluralRules::New(Isolate* isolate, Handle<Map> map, ...@@ -124,7 +124,7 @@ MaybeHandle<JSPluralRules> JSPluralRules::New(Isolate* isolate, Handle<Map> map,
std::unique_ptr<icu::PluralRules> icu_plural_rules; std::unique_ptr<icu::PluralRules> icu_plural_rules;
bool success = bool success =
CreateICUPluralRules(isolate, r.icu_locale, type, &icu_plural_rules); CreateICUPluralRules(isolate, r.icu_locale, type, &icu_plural_rules);
if (!success) { if (!success || icu_plural_rules.get() == nullptr) {
// Remove extensions and try again. // Remove extensions and try again.
icu::Locale no_extension_locale(r.icu_locale.getBaseName()); icu::Locale no_extension_locale(r.icu_locale.getBaseName());
success = CreateICUPluralRules(isolate, no_extension_locale, type, success = CreateICUPluralRules(isolate, no_extension_locale, type,
...@@ -133,13 +133,12 @@ MaybeHandle<JSPluralRules> JSPluralRules::New(Isolate* isolate, Handle<Map> map, ...@@ -133,13 +133,12 @@ MaybeHandle<JSPluralRules> JSPluralRules::New(Isolate* isolate, Handle<Map> map,
icu::number::NumberFormatter::withLocale(no_extension_locale) icu::number::NumberFormatter::withLocale(no_extension_locale)
.roundingMode(UNUM_ROUND_HALFUP); .roundingMode(UNUM_ROUND_HALFUP);
if (!success) { if (!success || icu_plural_rules.get() == nullptr) {
FATAL("Failed to create ICU PluralRules, are ICU data files missing?"); THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),
JSPluralRules);
} }
} }
CHECK_NOT_NULL(icu_plural_rules.get());
// 9. Perform ? SetNumberFormatDigitOptions(pluralRules, options, 0, 3). // 9. Perform ? SetNumberFormatDigitOptions(pluralRules, options, 0, 3).
Maybe<Intl::NumberFormatDigitOptions> maybe_digit_options = Maybe<Intl::NumberFormatDigitOptions> maybe_digit_options =
Intl::SetNumberFormatDigitOptions(isolate, options, 0, 3, false); Intl::SetNumberFormatDigitOptions(isolate, options, 0, 3, false);
......
...@@ -181,12 +181,12 @@ MaybeHandle<JSRelativeTimeFormat> JSRelativeTimeFormat::New( ...@@ -181,12 +181,12 @@ MaybeHandle<JSRelativeTimeFormat> JSRelativeTimeFormat::New(
number_format = number_format =
icu::NumberFormat::createInstance(icu_locale, UNUM_DECIMAL, status); icu::NumberFormat::createInstance(icu_locale, UNUM_DECIMAL, status);
} }
if (U_FAILURE(status)) { if (U_FAILURE(status) || number_format == nullptr) {
delete number_format; delete number_format;
FATAL("Failed to create ICU number format, are ICU data files missing?"); THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),
JSRelativeTimeFormat);
} }
} }
CHECK_NOT_NULL(number_format);
// Change UDISPCTX_CAPITALIZATION_NONE to other values if // Change UDISPCTX_CAPITALIZATION_NONE to other values if
// ECMA402 later include option to change capitalization. // ECMA402 later include option to change capitalization.
...@@ -195,13 +195,11 @@ MaybeHandle<JSRelativeTimeFormat> JSRelativeTimeFormat::New( ...@@ -195,13 +195,11 @@ MaybeHandle<JSRelativeTimeFormat> JSRelativeTimeFormat::New(
new icu::RelativeDateTimeFormatter(icu_locale, number_format, new icu::RelativeDateTimeFormatter(icu_locale, number_format,
toIcuStyle(style_enum), toIcuStyle(style_enum),
UDISPCTX_CAPITALIZATION_NONE, status); UDISPCTX_CAPITALIZATION_NONE, status);
if (U_FAILURE(status)) { if (U_FAILURE(status) || icu_formatter == nullptr) {
delete icu_formatter; delete icu_formatter;
FATAL( THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),
"Failed to create ICU relative date time formatter, are ICU data files " JSRelativeTimeFormat);
"missing?");
} }
CHECK_NOT_NULL(icu_formatter);
Handle<String> numbering_system_string = Handle<String> numbering_system_string =
isolate->factory()->NewStringFromAsciiChecked( isolate->factory()->NewStringFromAsciiChecked(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment