Merge pull request #2958 from kevin-bates/fix-2957-add-reason-to-json-errors

Add 'reason' field to JSON error responses
This commit is contained in:
Thomas Kluyver 2017-11-01 09:43:48 +00:00 committed by GitHub
commit 9a5c2c06ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -486,8 +486,10 @@ class APIHandler(IPythonHandler):
e = exc_info[1] e = exc_info[1]
if isinstance(e, HTTPError): if isinstance(e, HTTPError):
reply['message'] = e.log_message or message reply['message'] = e.log_message or message
reply['reason'] = e.reason
else: else:
reply['message'] = 'Unhandled error' reply['message'] = 'Unhandled error'
reply['reason'] = None
reply['traceback'] = ''.join(traceback.format_exception(*exc_info)) reply['traceback'] = ''.join(traceback.format_exception(*exc_info))
self.log.warning(reply['message']) self.log.warning(reply['message'])
self.finish(json.dumps(reply)) self.finish(json.dumps(reply))