From 86d6bfe11ffd42e327c0a74d1c9e28803695d771 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sat, 5 Oct 2013 17:22:13 +0000 Subject: [PATCH] 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 --- taskflow/exceptions.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/taskflow/exceptions.py b/taskflow/exceptions.py index c286424e..626ef007 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