def format_error(e):
# errback automatically wraps everything in a Twisted Failure
if isinstance(e, failure.Failure):
e = e.value
if isinstance(e, str):
err_string = e
elif six.PY2:
err_string = traceback.format_exc(e).rstrip()
else:
err_string = ''.join(traceback.format_exception(type(e), e, e.__traceback__)).rstrip()
if err_string == 'None':
# Reasonable heuristic for exceptions that were created by hand
last = traceback.format_stack()[-2]
err_string = '{}\n {}'.format(e, last)
# Quick and dirty hack for now.
err_string = err_string.replace('Connection to the other side was lost in a non-clean fashion', 'Connection to the other side was lost in a non-clean fashion (HINT: this generally actually means we got a connection refused error. Check that the remote is actually running.)')
return error.Error(err_string)
评论列表
文章目录