Skip to content

Commit

Permalink
Merge pull request #326 from dart-lang/safe_args
Browse files Browse the repository at this point in the history
catch parse exceptions from args
  • Loading branch information
vsmenon committed Sep 16, 2015
2 parents e5b3524 + 6f3710e commit 279194d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 9 additions & 1 deletion pkg/dev_compiler/bin/dartdevc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ void _showUsageAndExit() {
}

main(List<String> args) async {
var options = validateOptions(args);
var options;

try {
options = validateOptions(args);
} on FormatException catch (e) {
print('${e.message}\n');
_showUsageAndExit();
}

if (options == null || options.help) _showUsageAndExit();

setupLogger(options.logLevel, print);
Expand Down
11 changes: 9 additions & 2 deletions pkg/dev_compiler/bin/devrun.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@ main(List<String> args) async {
..add('--arrow-fn-bind-this')
..addAll(args);

CompilerOptions options = validateOptions(args, forceOutDir: true);
if (options == null || options.help) {
CompilerOptions options;

try {
options = validateOptions(args, forceOutDir: true);
} on FormatException catch (e) {
print('${e.message}\n');
_showUsageAndExit();
}

if (options == null || options.help) _showUsageAndExit();

if (options.inputs.length != 1) {
stderr.writeln("Please only specify one input to run");
_showUsageAndExit();
Expand Down

0 comments on commit 279194d

Please sign in to comment.