Attempt to extract traceback from exception

In py3.x and newer a exception has an attached
traceback so in the `from_exception` class method
we should try to extract that traceback if we are
able to.

Change-Id: Ia1c5cfddc259bd9de7cff1b672354670c2f4f839
This commit is contained in:
Joshua Harlow
2015-03-15 09:35:30 -07:00
parent f890a096de
commit 5d2fb53a34

View File

@@ -209,7 +209,12 @@ class Failure(object):
@classmethod
def from_exception(cls, exception):
"""Creates a failure object from a exception instance."""
return cls((type(exception), exception, None))
exc_info = (
type(exception),
exception,
getattr(exception, '__traceback__', None)
)
return cls(exc_info=exc_info)
@classmethod
def validate(cls, data):