diff --git a/packages/flutter_tools/lib/src/dart/generate_synthetic_packages.dart b/packages/flutter_tools/lib/src/dart/generate_synthetic_packages.dart index a0d33bf454..66ca9b38ef 100644 --- a/packages/flutter_tools/lib/src/dart/generate_synthetic_packages.dart +++ b/packages/flutter_tools/lib/src/dart/generate_synthetic_packages.dart @@ -9,6 +9,7 @@ import 'package:yaml/yaml.dart'; import '../base/common.dart'; import '../base/file_system.dart'; +import '../base/utils.dart'; import '../build_system/build_system.dart'; import '../build_system/targets/localizations.dart'; @@ -62,7 +63,14 @@ Future generateLocalizationsSyntheticPackage({ environment, ); - if (result == null || result.hasException) { - throwToolExit('Generating synthetic localizations package has failed.'); + if (result == null) { + throwToolExit('Generating synthetic localizations package failed: result is null.'); + } + if (result.hasException) { + throwToolExit( + 'Generating synthetic localizations package failed with ${result.exceptions.length} ${pluralize('error', result.exceptions.length)}:' + '\n\n' + '${result.exceptions.values.map((ExceptionMeasurement e) => e.exception).join('\n\n')}', + ); } } diff --git a/packages/flutter_tools/test/general.shard/dart/generate_synthetic_packages_test.dart b/packages/flutter_tools/test/general.shard/dart/generate_synthetic_packages_test.dart index 94e4867b0f..81bbb0e20d 100644 --- a/packages/flutter_tools/test/general.shard/dart/generate_synthetic_packages_test.dart +++ b/packages/flutter_tools/test/general.shard/dart/generate_synthetic_packages_test.dart @@ -45,7 +45,7 @@ void main() { ); final Completer completer = Completer(); final BuildResult exception = BuildResult(success: false, exceptions: { - 'hello': ExceptionMeasurement('hello', 'bar', null), + 'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), null), }); final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) { expect(target, const GenerateLocalizationsTarget()); @@ -58,7 +58,11 @@ void main() { environment: environment, buildSystem: buildSystem, ), - throwsToolExit(message: 'Generating synthetic localizations package has failed.'), + throwsToolExit(message: + 'Generating synthetic localizations package failed with 1 error:' + '\n\n' + 'FormatException: illegal character in input string', + ), ); await completer.future; }); @@ -90,7 +94,7 @@ void main() { ); final Completer completer = Completer(); final BuildResult exception = BuildResult(success: false, exceptions: { - 'hello': ExceptionMeasurement('hello', 'bar', null), + 'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), null), }); final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) { expect(target, const GenerateLocalizationsTarget()); @@ -103,7 +107,11 @@ void main() { environment: environment, buildSystem: buildSystem, ), - throwsToolExit(message: 'Generating synthetic localizations package has failed.'), + throwsToolExit(message: + 'Generating synthetic localizations package failed with 1 error:' + '\n\n' + 'FormatException: illegal character in input string', + ), ); await completer.future; }); @@ -133,7 +141,7 @@ void main() { ); final Completer completer = Completer(); final BuildResult exception = BuildResult(success: false, exceptions: { - 'hello': ExceptionMeasurement('hello', 'bar', null), + 'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), null), }); final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) { expect(target, const GenerateLocalizationsTarget()); @@ -146,7 +154,11 @@ void main() { environment: environment, buildSystem: buildSystem, ), - throwsToolExit(message: 'Generating synthetic localizations package has failed.'), + throwsToolExit(message: + 'Generating synthetic localizations package failed with 1 error:' + '\n\n' + 'FormatException: illegal character in input string', + ), ); await completer.future; });