From 6f3710e317fd8a31ce382f298e615a53e3591220 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 16 Sep 2015 16:33:29 -0700 Subject: [PATCH] catch parse exceptions from args --- pkg/dev_compiler/bin/dartdevc.dart | 10 +++++++++- pkg/dev_compiler/bin/devrun.dart | 11 +++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pkg/dev_compiler/bin/dartdevc.dart b/pkg/dev_compiler/bin/dartdevc.dart index 2a406d160d38..3e906b30bd78 100755 --- a/pkg/dev_compiler/bin/dartdevc.dart +++ b/pkg/dev_compiler/bin/dartdevc.dart @@ -23,7 +23,15 @@ void _showUsageAndExit() { } main(List 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); diff --git a/pkg/dev_compiler/bin/devrun.dart b/pkg/dev_compiler/bin/devrun.dart index 7e0bbabf96b9..4050ac927941 100755 --- a/pkg/dev_compiler/bin/devrun.dart +++ b/pkg/dev_compiler/bin/devrun.dart @@ -29,10 +29,17 @@ main(List 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();