Unverified Commit 76bc4625 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

migrate empty exceptions to tool exit with error message (#79898)

parent 15b9b58e
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../convert.dart'; import '../convert.dart';
...@@ -32,7 +33,7 @@ void generateLocalizations({ ...@@ -32,7 +33,7 @@ void generateLocalizations({
logger: logger, logger: logger,
); );
if (options.useSyntheticPackage && !flutterManifest.generateSyntheticPackage) { if (options.useSyntheticPackage && !flutterManifest.generateSyntheticPackage) {
logger.printError( throwToolExit(
'Attempted to generate localizations code without having ' 'Attempted to generate localizations code without having '
'the flutter: generate flag turned on.' 'the flutter: generate flag turned on.'
'\n' '\n'
...@@ -40,7 +41,6 @@ void generateLocalizations({ ...@@ -40,7 +41,6 @@ void generateLocalizations({
'been added and rebuild the project. Otherwise, the localizations ' 'been added and rebuild the project. Otherwise, the localizations '
'source code will not be importable.' 'source code will not be importable.'
); );
throw Exception();
} }
precacheLanguageAndRegionTags(); precacheLanguageAndRegionTags();
...@@ -71,8 +71,7 @@ void generateLocalizations({ ...@@ -71,8 +71,7 @@ void generateLocalizations({
..loadResources() ..loadResources()
..writeOutputFiles(logger, isFromYaml: true); ..writeOutputFiles(logger, isFromYaml: true);
} on L10nException catch (e) { } on L10nException catch (e) {
logger.printError(e.message); throwToolExit(e.message);
throw Exception();
} }
} }
......
...@@ -115,11 +115,10 @@ flutter: ...@@ -115,11 +115,10 @@ flutter:
projectDir: fileSystem.currentDirectory, projectDir: fileSystem.currentDirectory,
dependenciesDir: fileSystem.currentDirectory, dependenciesDir: fileSystem.currentDirectory,
), ),
throwsA(isA<Exception>()), throwsToolExit(
); message: 'Attempted to generate localizations code without having the '
expect( 'flutter: generate flag turned on.',
logger.errorText, ),
contains('Attempted to generate localizations code without having the flutter: generate flag turned on.'),
); );
}); });
......
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