Use the excutils.raise_with_cause after doing our type check

Change-Id: Ica886e67b4a75cb695d3ed51a3a952ca8f60f300
This commit is contained in:
Joshua Harlow 2015-06-16 15:33:28 -07:00
parent caf37be345
commit b42b2dff16

View File

@ -15,9 +15,9 @@
# under the License.
import os
import sys
import traceback
from oslo_utils import excutils
from oslo_utils import reflection
import six
@ -48,12 +48,7 @@ def raise_with_cause(exc_cls, message, *args, **kwargs):
"""
if not issubclass(exc_cls, TaskFlowException):
raise ValueError("Subclass of taskflow exception is required")
if 'cause' not in kwargs:
exc_type, exc, exc_tb = sys.exc_info()
if exc is not None:
kwargs['cause'] = exc
del(exc_type, exc, exc_tb)
six.raise_from(exc_cls(message, *args, **kwargs), kwargs.get('cause'))
excutils.raise_with_cause(exc_cls, message, *args, **kwargs)
class TaskFlowException(Exception):