CLI: don't catch+wrap WrongPasswordError

Also remove .explain, now that we no longer wrap it in TransferError
This commit is contained in:
Brian Warner 2016-04-25 17:03:36 -07:00
parent b96b052c96
commit e4a19748db
3 changed files with 7 additions and 13 deletions

View File

@ -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"])

View File

@ -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"))

View File

@ -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."""