{"thread":{"id":"13184","subject":"[StGit PATCH] Handle commandline parsing errors gracefully","startedAt":"2008-04-20T13:19:12Z","lastAt":"2008-04-20T13:19:12Z","messageCount":1,"participants":["Karl Hasselström"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"74803","messageId":"20080420131847.8824.87769.stgit@yoghurt","threadId":"13184","inReplyTo":null,"subject":"[StGit PATCH] Handle commandline parsing errors gracefully","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-04-20T13:19:12Z","receivedAt":"2008-04-20T13:19:12Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"The commandline option parser raises SystemExit after having explained\nto the user what she did wrong. A recent refactoring introduced a\ncatch-all \"except:\" at the top level, which caught the SystemExit and\nprinted a traceback.\n\nLet's just simply exit instead, like we used to.\n\nSigned-off-by: Karl Hasselström <kha@treskal.com>\n\n---\n\nThis goes on the \"master\" branch.\n\n stgit/main.py |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\n\ndiff --git a/stgit/main.py b/stgit/main.py\nindex 663fdec..aa1f8ef 100644\n--- a/stgit/main.py\n+++ b/stgit/main.py\n@@ -281,6 +281,10 @@ def main():\n         if debug_level > 0:\n             traceback.print_exc()\n         sys.exit(utils.STGIT_COMMAND_ERROR)\n+    except SystemExit:\n+        # Triggered by the option parser when it finds bad commandline\n+        # parameters.\n+        sys.exit(utils.STGIT_COMMAND_ERROR)\n     except KeyboardInterrupt:\n         sys.exit(utils.STGIT_GENERAL_ERROR)\n     except:\n"}]}