From 8c69acf70d7624b84f07999eb2d82be641a3bb6c Mon Sep 17 00:00:00 2001 From: Laurent Mazuel Date: Tue, 17 Jan 2017 12:19:07 -0800 Subject: [PATCH] Clarify validate error --- msrest/serialization.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/msrest/serialization.py b/msrest/serialization.py index 924cb6a..ee81c21 100644 --- a/msrest/serialization.py +++ b/msrest/serialization.py @@ -245,6 +245,7 @@ class Serializer(object): for attr, map in attributes.items(): attr_name = attr + debug_name = "{}.{}".format(class_name, attr_name) try: keys = self.flattten.split(map['key']) keys = [k.replace('\\.', '.') for k in keys] @@ -252,7 +253,7 @@ class Serializer(object): orig_attr = getattr(target_obj, attr) validation = target_obj._validation.get(attr_name, {}) orig_attr = self.validate( - orig_attr, attr_name, **validation) + orig_attr, debug_name, **validation) new_attr = self.serialize_data( orig_attr, attr_type, **kwargs) @@ -271,8 +272,8 @@ class Serializer(object): continue except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.".format( - attr_name, class_name) + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) raise_with_traceback(SerializationError, msg, err) else: return serialized