Merge pull request #5530 from cool-RR/patch-1

Fix exception causes in handlers.py
This commit is contained in:
Kevin Bates 2020-06-24 08:15:42 -07:00 committed by GitHub
commit db46c594bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -452,7 +452,7 @@ class IPythonHandler(AuthenticatedHandler):
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
@ -542,10 +542,10 @@ class IPythonHandler(AuthenticatedHandler):
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):