Merge pull request #11 from isethi/validation
Add description to exception messages
This commit is contained in:
commit
60c667e1fd
@ -44,8 +44,9 @@ class Model(dict):
|
|||||||
mutation[key] = value
|
mutation[key] = value
|
||||||
try:
|
try:
|
||||||
self.validate(mutation)
|
self.validate(mutation)
|
||||||
except exceptions.ValidationError:
|
except exceptions.ValidationError as exc:
|
||||||
msg = "Unable to set '%s' to '%s'" % (key, value)
|
msg = ("Unable to set '%s' to '%s'. Reason: %s"
|
||||||
|
% (key, value, str(exc)))
|
||||||
raise exceptions.InvalidOperation(msg)
|
raise exceptions.InvalidOperation(msg)
|
||||||
|
|
||||||
dict.__setitem__(self, key, value)
|
dict.__setitem__(self, key, value)
|
||||||
@ -57,8 +58,9 @@ class Model(dict):
|
|||||||
del mutation[key]
|
del mutation[key]
|
||||||
try:
|
try:
|
||||||
self.validate(mutation)
|
self.validate(mutation)
|
||||||
except exceptions.ValidationError:
|
except exceptions.ValidationError as exc:
|
||||||
msg = "Unable to delete attribute '%s'" % (key)
|
msg = ("Unable to delete attribute '%s'. Reason: %s"
|
||||||
|
% (key, str(exc)))
|
||||||
raise exceptions.InvalidOperation(msg)
|
raise exceptions.InvalidOperation(msg)
|
||||||
|
|
||||||
dict.__delitem__(self, key)
|
dict.__delitem__(self, key)
|
||||||
|
Loading…
Reference in New Issue
Block a user