summaryrefslogtreecommitdiff
path: root/taskflow/engines/worker_based
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2015-02-11 18:22:20 -0800
committerJoshua Harlow <harlowja@yahoo-inc.com>2015-04-03 16:04:46 -0700
commitaa8be4b8f5f55cc4e11088dcb122b34345f56cec (patch)
treea46a6e3845de3ed22dfdfe8a14be2934681cca86 /taskflow/engines/worker_based
parent97c170473011e24da5481d2e3fd82bf8e6778bed (diff)
downloadtaskflow-aa8be4b8f5f55cc4e11088dcb122b34345f56cec.tar.gz
Use the ability to chain exceptions correctly
In the zookeeper jobboard (and persistence backends) we are associating the cause of a new exception when raising a exception. Using the new exception helper we can make this work better on py2.x and py3.x so that the py3.x version has the chain setup correctly (while the py2.x version just uses the class 'cause' attribute instead). Change-Id: Ieeac2f70e1834d4612556565762ffd3be3e5b5a1
Diffstat (limited to 'taskflow/engines/worker_based')
-rw-r--r--taskflow/engines/worker_based/protocol.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/taskflow/engines/worker_based/protocol.py b/taskflow/engines/worker_based/protocol.py
index 1ecfcef..867f536 100644
--- a/taskflow/engines/worker_based/protocol.py
+++ b/taskflow/engines/worker_based/protocol.py
@@ -165,13 +165,17 @@ class Notify(Message):
except su.ValidationError as e:
cls_name = reflection.get_class_name(cls, fully_qualified=False)
if response:
- raise excp.InvalidFormat("%s message response data not of the"
- " expected format: %s"
- % (cls_name, e.message), e)
+ excp.raise_with_cause(excp.InvalidFormat,
+ "%s message response data not of the"
+ " expected format: %s" % (cls_name,
+ e.message),
+ cause=e)
else:
- raise excp.InvalidFormat("%s message sender data not of the"
- " expected format: %s"
- % (cls_name, e.message), e)
+ excp.raise_with_cause(excp.InvalidFormat,
+ "%s message sender data not of the"
+ " expected format: %s" % (cls_name,
+ e.message),
+ cause=e)
_WorkUnit = collections.namedtuple('_WorkUnit', ['task_cls', 'task_name',
@@ -361,9 +365,11 @@ class Request(Message):
su.schema_validate(data, cls.SCHEMA)
except su.ValidationError as e:
cls_name = reflection.get_class_name(cls, fully_qualified=False)
- raise excp.InvalidFormat("%s message response data not of the"
- " expected format: %s"
- % (cls_name, e.message), e)
+ excp.raise_with_cause(excp.InvalidFormat,
+ "%s message response data not of the"
+ " expected format: %s" % (cls_name,
+ e.message),
+ cause=e)
else:
# Validate all failure dictionaries that *may* be present...
failures = []
@@ -505,9 +511,11 @@ class Response(Message):
su.schema_validate(data, cls.SCHEMA)
except su.ValidationError as e:
cls_name = reflection.get_class_name(cls, fully_qualified=False)
- raise excp.InvalidFormat("%s message response data not of the"
- " expected format: %s"
- % (cls_name, e.message), e)
+ excp.raise_with_cause(excp.InvalidFormat,
+ "%s message response data not of the"
+ " expected format: %s" % (cls_name,
+ e.message),
+ cause=e)
else:
state = data['state']
if state == FAILURE and 'result' in data: