From ed3b0e45943b7f21543ea194b7eac9fd3cd42ca5 Mon Sep 17 00:00:00 2001 From: Kevin Bates Date: Tue, 31 Oct 2017 10:40:50 -0700 Subject: [PATCH] Set reason on HTTP errors, None otherwise. --- notebook/base/handlers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notebook/base/handlers.py b/notebook/base/handlers.py index 32b96f895..696bdd00f 100755 --- a/notebook/base/handlers.py +++ b/notebook/base/handlers.py @@ -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))