mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-30 12:11:32 +08:00
Set reason on HTTP errors, None otherwise.
This commit is contained in:
parent
b24aa5e023
commit
ed3b0e4594
@ -461,16 +461,16 @@ class APIHandler(IPythonHandler):
|
|||||||
message = responses.get(status_code, 'Unknown HTTP Error')
|
message = responses.get(status_code, 'Unknown HTTP Error')
|
||||||
reply = {
|
reply = {
|
||||||
'message': message,
|
'message': message,
|
||||||
# some clients expect 'reason' to exist and equate to status_code text
|
|
||||||
'reason': message,
|
|
||||||
}
|
}
|
||||||
exc_info = kwargs.get('exc_info')
|
exc_info = kwargs.get('exc_info')
|
||||||
if exc_info:
|
if exc_info:
|
||||||
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))
|
||||||
|
Loading…
Reference in New Issue
Block a user