Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Make an error object to conform JSON API spec
  • Loading branch information
hnakamur committed Sep 8, 2015
commit d6d3f3e582cfa6a9e69ba2f38c94f5e852840173
9 changes: 7 additions & 2 deletions rest_framework_json_api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ def exception_handler(exc, context):
field = format_value(field)
pointer = '/data/attributes/{}'.format(field)
# see if they passed a dictionary to ValidationError manually
# or a string in case of AuthenticationError
if isinstance(error, dict) or isinstance(error, str):
if isinstance(error, dict):
errors.append(error)
# or a string in case of AuthenticationError
elif isinstance(error, str):
# An error MUST be a JSON object in JSON API spec
errors.append({
'detail': error
})
else:
for message in error:
errors.append({
Expand Down