Permalink
Browse files

Improve error message handling

  • Loading branch information...
1 parent 5599bff commit c9fa7623ff31d585c91cd37fa0d919bb91775dae Ymage committed Apr 1, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 cornice/validators.py
View
10 cornice/validators.py 100644 → 100755
@@ -34,14 +34,14 @@ def _validate_fields(location, data):
request.errors.add(location, attr.name,
"%s is missing" % attr.name)
else:
- if not attr.name in data:
- request.validated[attr.name] = attr.missing
- continue
try:
- deserialized = attr.deserialize(data[attr.name])
+ if not attr.name in data:
+ deserialized = attr.deserialize(None)
+ else:
+ deserialized = attr.deserialize(data[attr.name])
except Invalid, e:
# the struct is invalid
- request.errors.add(location, attr.name, e.msg)
+ request.errors.add(location, attr.name, e.asdict()[attr.name])
else:
request.validated[attr.name] = deserialized

0 comments on commit c9fa762

Please sign in to comment.