Use the excutils.raise_with_cause
after doing our type check
Change-Id: Ica886e67b4a75cb695d3ed51a3a952ca8f60f300
This commit is contained in:
parent
caf37be345
commit
b42b2dff16
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user