From b42b2dff164ca5ca5f40fdc93e823aa37676ff62 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Tue, 16 Jun 2015 15:33:28 -0700 Subject: [PATCH] Use the `excutils.raise_with_cause` after doing our type check Change-Id: Ica886e67b4a75cb695d3ed51a3a952ca8f60f300 --- taskflow/exceptions.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/taskflow/exceptions.py b/taskflow/exceptions.py index 3d153ffc1..2f22b4f7a 100644 --- a/taskflow/exceptions.py +++ b/taskflow/exceptions.py @@ -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):