From aa772858f52aecc660208737f4663b2da13a280b Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sun, 15 Jan 2017 17:35:46 -0500 Subject: [PATCH] cli: print useful error when --tor is requested but unavailable --- src/wormhole/cli/cli.py | 4 ++-- src/wormhole/errors.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wormhole/cli/cli.py b/src/wormhole/cli/cli.py index 9ce3d07..9b202b9 100644 --- a/src/wormhole/cli/cli.py +++ b/src/wormhole/cli/cli.py @@ -9,7 +9,7 @@ from . import public_relay from .. import __version__ from ..timing import DebugTiming from ..errors import (WrongPasswordError, WelcomeError, KeyFormatError, - TransferError) + TransferError, NoTorError) from twisted.internet.defer import inlineCallbacks, maybeDeferred from twisted.python.failure import Failure from twisted.internet.task import react @@ -104,7 +104,7 @@ def _dispatch_command(reactor, cfg, command): try: yield maybeDeferred(command) - except (WrongPasswordError, KeyFormatError) as e: + except (WrongPasswordError, KeyFormatError, NoTorError) as e: msg = fill("ERROR: " + dedent(e.__doc__)) print(msg, file=stderr) raise SystemExit(1) diff --git a/src/wormhole/errors.py b/src/wormhole/errors.py index cf039fd..7eff520 100644 --- a/src/wormhole/errors.py +++ b/src/wormhole/errors.py @@ -55,3 +55,6 @@ class WormholeClosedError(InternalError): class TransferError(Exception): """Something bad happened and the transfer failed.""" + +class NoTorError(Exception): + """--tor was requested, but 'txtorcon' is not installed."""