diff --git a/src/wormhole/cli/cmd_receive.py b/src/wormhole/cli/cmd_receive.py index c759ed0..ea24a9e 100644 --- a/src/wormhole/cli/cmd_receive.py +++ b/src/wormhole/cli/cmd_receive.py @@ -16,6 +16,10 @@ class RespondError(Exception): def __init__(self, response): self.response = response +class TransferRejectedError(RespondError): + def __init__(self): + RespondError.__init__(self, "transfer rejected") + def receive(args, reactor=reactor): """I implement 'wormhole receive'. I return a Deferred that fires with None (for success), or signals one of the following errors: @@ -230,7 +234,7 @@ class TwistedReceiver: if os.path.exists(abs_destname): self._msg(u"Error: refusing to overwrite existing %s %s" % (mode, destname)) - raise RespondError("%s already exists" % mode) + raise TransferRejectedError() return abs_destname def _ask_permission(self): @@ -241,7 +245,7 @@ class TwistedReceiver: break print(u"transfer rejected", file=sys.stderr) t.detail(answer="no") - raise RespondError("transfer rejected") + raise TransferRejectedError() t.detail(answer="yes") def _send_permission(self, w): diff --git a/src/wormhole/test/test_scripts.py b/src/wormhole/test/test_scripts.py index ea6c4fc..5627eca 100644 --- a/src/wormhole/test/test_scripts.py +++ b/src/wormhole/test/test_scripts.py @@ -491,10 +491,10 @@ class PregeneratedCode(ServerBase, ScriptsBase, unittest.TestCase): # both sides will fail because of the pre-existing file f = yield self.assertFailure(send_d, TransferError) - self.assertEqual(str(f), "remote error, transfer abandoned: file already exists") + self.assertEqual(str(f), "remote error, transfer abandoned: transfer rejected") f = yield self.assertFailure(receive_d, TransferError) - self.assertEqual(str(f), "file already exists") + self.assertEqual(str(f), "transfer rejected") send_stdout = send_cfg.stdout.getvalue() send_stderr = send_cfg.stderr.getvalue()