Print proper tracebacks when inlineCallbacks + yield involved

This commit is contained in:
meejah 2016-08-14 16:50:29 -06:00
parent 2a332471d3
commit 026c8fd093

View File

@ -3,7 +3,7 @@ from __future__ import print_function
import os
import time
start = time.time()
import traceback
from os.path import expanduser, exists
from textwrap import fill, dedent
from sys import stdout, stderr
from . import public_relay
@ -11,6 +11,7 @@ from .. import __version__
from ..timing import DebugTiming
from ..errors import WrongPasswordError, WelcomeError, KeyFormatError
from twisted.internet.defer import inlineCallbacks, maybeDeferred
from twisted.python.failure import Failure
from twisted.internet.task import react
import click
@ -111,7 +112,10 @@ def _dispatch_command(reactor, cfg, command):
msg = fill("ERROR: " + dedent(e.__doc__))
print(msg, file=stderr)
except Exception as e:
traceback.print_exc()
# this prints a proper traceback, whereas
# traceback.print_exc() just prints a TB to the "yield"
# line above ...
Failure().printTraceback(file=stderr)
print("ERROR:", e, file=stderr)
raise SystemExit(1)