From 58c763963551d831a64457369ffb8e5d59b5dc17 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 8 Dec 2016 16:48:12 -0800 Subject: [PATCH] CLI: exit with rc=1 upon errors --- src/wormhole/cli/cli.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wormhole/cli/cli.py b/src/wormhole/cli/cli.py index 4f0a341..42e4608 100644 --- a/src/wormhole/cli/cli.py +++ b/src/wormhole/cli/cli.py @@ -100,17 +100,16 @@ def _dispatch_command(reactor, cfg, command): try: yield maybeDeferred(command) - except WrongPasswordError as e: + except (WrongPasswordError, KeyFormatError) as e: msg = fill("ERROR: " + dedent(e.__doc__)) print(msg, file=stderr) + raise SystemExit(1) except WelcomeError as e: msg = fill("ERROR: " + dedent(e.__doc__)) print(msg, file=stderr) print(file=stderr) print(str(e), file=stderr) - except KeyFormatError as e: - msg = fill("ERROR: " + dedent(e.__doc__)) - print(msg, file=stderr) + raise SystemExit(1) except Exception as e: # this prints a proper traceback, whereas # traceback.print_exc() just prints a TB to the "yield"