diff --git a/src/wormhole/cli/cmd_receive.py b/src/wormhole/cli/cmd_receive.py index b2fb894..d1b2ca2 100644 --- a/src/wormhole/cli/cmd_receive.py +++ b/src/wormhole/cli/cmd_receive.py @@ -3,7 +3,7 @@ import os, sys, json, binascii, six, tempfile, zipfile from tqdm import tqdm from twisted.internet import reactor, defer from twisted.internet.defer import inlineCallbacks, returnValue -from ..twisted.transcribe import Wormhole, WrongPasswordError +from ..twisted.transcribe import Wormhole from ..twisted.transit import TransitReceiver from ..errors import TransferError @@ -113,10 +113,8 @@ class TwistedReceiver: @inlineCallbacks def get_data(self, w): - try: - them_bytes = yield w.get_data() - except WrongPasswordError as e: - raise TransferError(u"ERROR: " + e.explain()) + # this may raise WrongPasswordError + them_bytes = yield w.get_data() them_d = json.loads(them_bytes.decode("utf-8")) if "error" in them_d: raise TransferError(u"ERROR: " + them_d["error"]) diff --git a/src/wormhole/cli/cmd_send.py b/src/wormhole/cli/cmd_send.py index 652a370..29740cd 100644 --- a/src/wormhole/cli/cmd_send.py +++ b/src/wormhole/cli/cmd_send.py @@ -5,7 +5,7 @@ from twisted.protocols import basic from twisted.internet import reactor from twisted.internet.defer import inlineCallbacks, returnValue from ..errors import TransferError -from ..twisted.transcribe import Wormhole, WrongPasswordError +from ..twisted.transcribe import Wormhole from ..twisted.transit import TransitSender APPID = u"lothar.com/wormhole/text-or-file-xfer" @@ -87,10 +87,8 @@ def send(args, reactor=reactor): my_phase1_bytes = json.dumps(phase1).encode("utf-8") yield w.send_data(my_phase1_bytes) - try: - them_phase1_bytes = yield w.get_data() - except WrongPasswordError as e: - raise TransferError(e.explain()) + # this may raise WrongPasswordError + them_phase1_bytes = yield w.get_data() them_phase1 = json.loads(them_phase1_bytes.decode("utf-8")) diff --git a/src/wormhole/errors.py b/src/wormhole/errors.py index 2846626..898bafd 100644 --- a/src/wormhole/errors.py +++ b/src/wormhole/errors.py @@ -1,4 +1,4 @@ -import functools, textwrap +import functools class ServerError(Exception): def __init__(self, message, relay): @@ -28,8 +28,6 @@ class WrongPasswordError(Exception): chance. """ # or the data blob was corrupted, and that's why decrypt failed - def explain(self): - return textwrap.dedent(self.__doc__) class ReflectionAttack(Exception): """An attacker (or bug) reflected our outgoing message back to us."""