Skip to content

Commit de82378

Browse files
committed
Add reason argument to set_status() so that custom messages flow
Without adding a named argument of `reason` to tornado's `set_status()` method, messages associated with a thrown HTTPError will not be returned to the caller. Instead, the reason corresponding to the built-in status code is returned. In addition, because the reason argument is used, enforcement of a built in status code is skipped, thereby allowing for the optional use of non-builtin status codes. Fixes #283
1 parent c93958c commit de82378

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,8 @@ docs/_build/
5656
# PyBuilder
5757
target/
5858

59+
# PyCharm
60+
.idea/
61+
5962
.DS_Store
6063
.ipynb_checkpoints/

kernel_gateway/mixins.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,5 @@ def write_error(self, status_code, **kwargs):
125125
reply['reason'] = custom_reason
126126

127127
self.set_header('Content-Type', 'application/json')
128-
self.set_status(status_code)
128+
self.set_status(status_code, reason=reply['reason'])
129129
self.finish(json.dumps(reply))

0 commit comments

Comments
 (0)