diff options
| author | Joshua Harlow <harlowja@gmail.com> | 2013-10-05 17:22:13 +0000 |
|---|---|---|
| committer | Joshua Harlow <harlowja@gmail.com> | 2013-10-05 17:24:30 +0000 |
| commit | 86d6bfe11ffd42e327c0a74d1c9e28803695d771 (patch) | |
| tree | b59a9178909751016c9b69726438956e65f4d8f5 /taskflow/exceptions.py | |
| parent | 91136532ed5ee13420378ebb61956b964889ed30 (diff) | |
| download | taskflow-86d6bfe11ffd42e327c0a74d1c9e28803695d771.tar.gz | |
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
Diffstat (limited to 'taskflow/exceptions.py')
| -rw-r--r-- | taskflow/exceptions.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/taskflow/exceptions.py b/taskflow/exceptions.py index c286424..626ef00 100644 --- a/taskflow/exceptions.py +++ b/taskflow/exceptions.py @@ -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 |
