diff options
author | iccha.sethi <iccha.sethi@rackspace.com> | 2013-09-06 12:14:25 -0400 |
---|---|---|
committer | iccha.sethi <iccha.sethi@rackspace.com> | 2013-09-06 13:59:26 -0400 |
commit | 97d6f13fe2d9cbef212697aa5eacc165333d46a7 (patch) | |
tree | 0f0c66e6c6b9b609788f9a8a819b6fdf34c89534 /warlock/model.py | |
parent | 1a0de8a67df8282c42f71014cc871684e8d7c0cf (diff) | |
download | warlock-97d6f13fe2d9cbef212697aa5eacc165333d46a7.tar.gz |
Add description to exception messages
Add description to exception messages, so users know how they
violated the schema.
Diffstat (limited to 'warlock/model.py')
-rw-r--r-- | warlock/model.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/warlock/model.py b/warlock/model.py index 1bc3f76..e026bbb 100644 --- a/warlock/model.py +++ b/warlock/model.py @@ -44,8 +44,9 @@ class Model(dict): mutation[key] = value try: self.validate(mutation) - except exceptions.ValidationError: - msg = "Unable to set '%s' to '%s'" % (key, value) + except exceptions.ValidationError as exc: + msg = ("Unable to set '%s' to '%s'. Reason: %s" + % (key, value, str(exc))) raise exceptions.InvalidOperation(msg) dict.__setitem__(self, key, value) @@ -57,8 +58,9 @@ class Model(dict): del mutation[key] try: self.validate(mutation) - except exceptions.ValidationError: - msg = "Unable to delete attribute '%s'" % (key) + except exceptions.ValidationError as exc: + msg = ("Unable to delete attribute '%s'. Reason: %s" + % (key, str(exc))) raise exceptions.InvalidOperation(msg) dict.__delitem__(self, key) |