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:
@@ -209,7 +209,12 @@ class Failure(object):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_exception(cls, exception):
|
def from_exception(cls, exception):
|
||||||
"""Creates a failure object from a exception instance."""
|
"""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
|
@classmethod
|
||||||
def validate(cls, data):
|
def validate(cls, data):
|
||||||
|
|||||||
Reference in New Issue
Block a user