Skip to content

Fix exception causes in handlers.py #5530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions notebook/base/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def check_xsrf_cookie(self):
msg = "Blocking Cross Origin request from {}.".format(referer)
else:
msg = "Blocking request from unknown origin"
raise web.HTTPError(403, msg)
raise web.HTTPError(403, msg) from e
else:
raise

Expand Down Expand Up @@ -542,10 +542,10 @@ def get_json_body(self):
body = self.request.body.strip().decode(u'utf-8')
try:
model = json.loads(body)
except Exception:
except Exception as e:
self.log.debug("Bad JSON: %r", body)
self.log.error("Couldn't parse JSON", exc_info=True)
raise web.HTTPError(400, u'Invalid JSON in body of request')
raise web.HTTPError(400, u'Invalid JSON in body of request') from e
return model

def write_error(self, status_code, **kwargs):
Expand Down