From ebe3d6de186bb721a98dcbef3e5aead787a93fb4 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sun, 15 Mar 2015 18:39:24 -0700 Subject: [PATCH] Just use the class name instead of TYPE constant The TYPE constant is more of an internal protocol detail and is not the best constant to use in exceptions that tell the received data is invalid, instead just prefer and use the class name instead which is more relevant than the TYPE constant. Change-Id: I60652a149eb1a3c3d8523544c355044bbd6fec94 --- taskflow/engines/worker_based/protocol.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/taskflow/engines/worker_based/protocol.py b/taskflow/engines/worker_based/protocol.py index 34dcd506..934f837f 100644 --- a/taskflow/engines/worker_based/protocol.py +++ b/taskflow/engines/worker_based/protocol.py @@ -162,14 +162,15 @@ class Notify(Message): try: su.schema_validate(data, schema) 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.TYPE, e.message), e) + % (cls_name, e.message), e) else: raise excp.InvalidFormat("%s message sender data not of the" " expected format: %s" - % (cls.TYPE, e.message), e) + % (cls_name, e.message), e) _WorkUnit = collections.namedtuple('_WorkUnit', ['task_cls', 'task_name', @@ -358,9 +359,10 @@ class Request(Message): try: 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.TYPE, e.message), e) + % (cls_name, e.message), e) else: # Validate all failure dictionaries that *may* be present... failures = [] @@ -501,9 +503,10 @@ class Response(Message): try: 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.TYPE, e.message), e) + % (cls_name, e.message), e) else: state = data['state'] if state == FAILURE and 'result' in data: