mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +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')
|
||||
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))
|
||||
|
Loading…
Reference in New Issue
Block a user