diff --git a/pkg/compiler/lib/src/apiimpl.dart b/pkg/compiler/lib/src/apiimpl.dart index 8b78684126c8..6c2f9c09521d 100644 --- a/pkg/compiler/lib/src/apiimpl.dart +++ b/pkg/compiler/lib/src/apiimpl.dart @@ -381,13 +381,17 @@ class Compiler extends leg.Compiler { } // The input provider may put a trailing 0 byte when it reads a source // file, which confuses the package config parser. - if (packageConfigContents.length > 0 - && packageConfigContents.last == 0) { + if (packageConfigContents.length > 0 && + packageConfigContents.last == 0) { packageConfigContents = packageConfigContents.sublist( 0, packageConfigContents.length - 1); } packages = new MapPackages(pkgs.parse(packageConfigContents, packageConfig)); + }).catchError((error) { + reportError(NO_LOCATION_SPANNABLE, MessageKind.INVALID_PACKAGE_CONFIG, + {'uri': packageConfig, 'exception': error}); + packages = Packages.noPackages; }); } else { if (packagesDiscoveryProvider == null) { diff --git a/pkg/compiler/lib/src/warnings.dart b/pkg/compiler/lib/src/warnings.dart index 5e5d603ae0c5..6108da10fe79 100644 --- a/pkg/compiler/lib/src/warnings.dart +++ b/pkg/compiler/lib/src/warnings.dart @@ -252,6 +252,7 @@ enum MessageKind { INVALID_OVERRIDE_METHOD, INVALID_OVERRIDE_SETTER, INVALID_OVERRIDE_SETTER_WITH_FIELD, + INVALID_PACKAGE_CONFIG, INVALID_PACKAGE_URI, INVALID_PARAMETER, INVALID_RECEIVER_IN_INITIALIZER, @@ -2224,6 +2225,13 @@ import '../../Udyn[mic ils/expect.dart'; main() {} """]), + MessageKind.INVALID_PACKAGE_CONFIG: + const MessageTemplate(MessageKind.INVALID_PACKAGE_CONFIG, + """Package config file '#{uri}' is invalid. +#{exception}""", + howToFix: DONT_KNOW_HOW_TO_FIX + ), + MessageKind.INVALID_PACKAGE_URI: const MessageTemplate(MessageKind.INVALID_PACKAGE_URI, "'#{uri}' is not a valid package URI (#{exception}).",