Set reason on HTTP errors, None otherwise.

This commit is contained in:
Kevin Bates 2017-10-31 10:40:50 -07:00
parent b24aa5e023
commit ed3b0e4594

View File

@ -461,16 +461,16 @@ class APIHandler(IPythonHandler):
message = responses.get(status_code, 'Unknown HTTP Error')
reply = {
'message': message,
# some clients expect 'reason' to exist and equate to status_code text
'reason': message,
}
exc_info = kwargs.get('exc_info')
if exc_info:
e = exc_info[1]
if isinstance(e, HTTPError):
reply['message'] = e.log_message or message
reply['reason'] = e.reason
else:
reply['message'] = 'Unhandled error'
reply['reason'] = None
reply['traceback'] = ''.join(traceback.format_exception(*exc_info))
self.log.warning(reply['message'])
self.finish(json.dumps(reply))