Some small exception cleanups

Whitespace change and compare directly
to none since user exceptions may have
overloaded the boolean operator and
avoid checking the exception classes
if the input is empty in the first place.

Change-Id: I426741bbc23181e96084383eaf77daa1d612ab59
This commit is contained in:
Joshua Harlow
2013-10-05 17:22:13 +00:00
parent 91136532ed
commit 86d6bfe11f

View File

@@ -101,7 +101,7 @@ class WrappedFailure(TaskFlowException):
self._causes = []
for cause in causes:
if cause.check(type(self)) and cause.exception:
# flatten wrapped failures
# NOTE(imelnikov): flatten wrapped failures
self._causes.extend(cause.exception)
else:
self._causes.append(cause)
@@ -122,11 +122,13 @@ class WrappedFailure(TaskFlowException):
of given type, the corresponding argument is returned. Else,
None is returned.
"""
if not exc_classes:
return None
for cause in self:
result = cause.check(*exc_classes)
if result:
if result is not None:
return result
return None
def __str__(self):
return 'Wrapped Failure: %s' % self._causes
return 'WrappedFailure: %s' % self._causes