From e8d3689a3acf184ecdd6ea8ac6c0b7ba482a8c6d Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sun, 24 Apr 2016 12:10:51 -0700 Subject: [PATCH] runner: display TransferErrors better These are known failures (like file-not-found, transfer rejected, etc). Display the error message, but not a traceback. --- src/wormhole/cli/runner.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wormhole/cli/runner.py b/src/wormhole/cli/runner.py index 8687b22..3142452 100644 --- a/src/wormhole/cli/runner.py +++ b/src/wormhole/cli/runner.py @@ -2,6 +2,7 @@ from __future__ import print_function import os, sys from twisted.internet.defer import maybeDeferred from twisted.internet.task import react +from ..errors import TransferError from ..timing import DebugTiming from .cli_args import parser @@ -41,6 +42,11 @@ def run(reactor, argv, cwd, stdout, stderr, executable=None): timing.write(args.dump_timing, stderr) return res d.addBoth(_maybe_dump_timing) + def _explain_error(f): + f.trap(TransferError) + print("ERROR:", f.value, file=stderr) + raise SystemExit(1) + d.addErrback(_explain_error) def _rc(rc): raise SystemExit(rc) d.addCallback(_rc)