runner: display TransferErrors better

These are known failures (like file-not-found, transfer rejected, etc).
Display the error message, but not a traceback.
This commit is contained in:
Brian Warner 2016-04-24 12:10:51 -07:00
parent 86edf96412
commit e8d3689a3a

View File

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