From: Karl Hasselström Date: Sun, 20 Apr 2008 13:17:17 +0000 (+0200) Subject: Handle commandline parsing errors gracefully X-Git-Tag: v0.15-rc1~245 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/f3167489c16538cea5835bff466bfea8acfc25cb Handle commandline parsing errors gracefully The commandline option parser raises SystemExit after having explained to the user what she did wrong. A recent refactoring introduced a catch-all "except:" at the top level, which caught the SystemExit and printed a traceback. Let's just simply exit instead, like we used to. Signed-off-by: Karl Hasselström --- diff --git a/stgit/main.py b/stgit/main.py index 663fdec..aa1f8ef 100644 --- a/stgit/main.py +++ b/stgit/main.py @@ -281,6 +281,10 @@ def main(): if debug_level > 0: traceback.print_exc() sys.exit(utils.STGIT_COMMAND_ERROR) + except SystemExit: + # Triggered by the option parser when it finds bad commandline + # parameters. + sys.exit(utils.STGIT_COMMAND_ERROR) except KeyboardInterrupt: sys.exit(utils.STGIT_GENERAL_ERROR) except: