cmd-twisted: report exceptions better

The previous scheme would swallow the real traceback, making debugging
difficult.
This commit is contained in:
Brian Warner 2016-03-03 12:22:25 -08:00
parent 08a5e6043a
commit 4f5e037d39
2 changed files with 6 additions and 4 deletions

View File

@ -22,13 +22,14 @@ def receive_twisted_sync(args):
rc.extend([True, res]) rc.extend([True, res])
reactor.stop() reactor.stop()
def _err(f): def _err(f):
rc.extend([False, f.value]) rc.extend([False, f])
reactor.stop() reactor.stop()
d.addCallbacks(_done, _err) d.addCallbacks(_done, _err)
reactor.run() reactor.run()
if rc[0]: if rc[0]:
return rc[1] return rc[1]
raise rc[1] print(str(rc[1]))
rc[1].raiseException()
def receive_twisted(args): def receive_twisted(args):
return TwistedReceiver(args).go() return TwistedReceiver(args).go()

View File

@ -24,13 +24,14 @@ def send_twisted_sync(args):
rc.extend([True, res]) rc.extend([True, res])
reactor.stop() reactor.stop()
def _err(f): def _err(f):
rc.extend([False, f.value]) rc.extend([False, f])
reactor.stop() reactor.stop()
d.addCallbacks(_done, _err) d.addCallbacks(_done, _err)
reactor.run() reactor.run()
if rc[0]: if rc[0]:
return rc[1] return rc[1]
raise rc[1] print(str(rc[1]))
rc[1].raiseException()
@inlineCallbacks @inlineCallbacks
def send_twisted(args): def send_twisted(args):