utils: return JSON for exceptions during JSON serialization (#53594)

This commit is contained in:
Benjamin Dauvergne 2021-04-30 12:33:10 +02:00
parent f1a8b5ac25
commit 52a932316b
1 changed files with 2 additions and 2 deletions

View File

@ -133,6 +133,7 @@ class to_json(object):
data = self.obj_to_response(req, resp)
status = 200
return self.render_data(req, data, status)
except Exception as e:
extras = {'method': req.method, 'exception': exception_to_text(e), 'request': req}
if req.method == 'POST':
@ -171,5 +172,4 @@ class to_json(object):
status = 403
else:
status = self.error_code
return self.render_data(req, data, status)
return self.render_data(req, data, status)