Skip to content

Commit 279194d

Browse files
committed
Merge pull request #326 from dart-lang/safe_args
catch parse exceptions from args
2 parents e5b3524 + 6f3710e commit 279194d

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

pkg/dev_compiler/bin/dartdevc.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ void _showUsageAndExit() {
2323
}
2424

2525
main(List<String> args) async {
26-
var options = validateOptions(args);
26+
var options;
27+
28+
try {
29+
options = validateOptions(args);
30+
} on FormatException catch (e) {
31+
print('${e.message}\n');
32+
_showUsageAndExit();
33+
}
34+
2735
if (options == null || options.help) _showUsageAndExit();
2836

2937
setupLogger(options.logLevel, print);

pkg/dev_compiler/bin/devrun.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,17 @@ main(List<String> args) async {
2929
..add('--arrow-fn-bind-this')
3030
..addAll(args);
3131

32-
CompilerOptions options = validateOptions(args, forceOutDir: true);
33-
if (options == null || options.help) {
32+
CompilerOptions options;
33+
34+
try {
35+
options = validateOptions(args, forceOutDir: true);
36+
} on FormatException catch (e) {
37+
print('${e.message}\n');
3438
_showUsageAndExit();
3539
}
40+
41+
if (options == null || options.help) _showUsageAndExit();
42+
3643
if (options.inputs.length != 1) {
3744
stderr.writeln("Please only specify one input to run");
3845
_showUsageAndExit();

0 commit comments

Comments
 (0)