Handle the error if we try to access a deferred-loaded locale that hasn't been initialized.
This fixes a regression from Friday in dart/build_defs/tests/intl:message_extraction_test
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=123032388
diff --git a/lib/generate_localized.dart b/lib/generate_localized.dart
index b302f45..f6f3c44 100644
--- a/lib/generate_localized.dart
+++ b/lib/generate_localized.dart
@@ -180,8 +180,16 @@
});
}
+bool _messagesExistFor(String locale) {
+ var messages;
+ try {
+ messages = _findExact(locale);
+ } catch (e) {}
+ return messages != null;
+}
+
MessageLookupByLibrary _findGeneratedMessagesFor(locale) {
- var actualLocale = Intl.verifiedLocale(locale, (x) => _findExact(x) != null,
+ var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor,
onFailure: (_) => null);
if (actualLocale == null) return null;
return _findExact(actualLocale);