Skip to content

Commit

Permalink
Update base.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry Zhou committed Oct 11, 2021
1 parent 77126c4 commit 7131379
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion biothings/web/handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,19 @@ def on_finish(self):
super().on_finish()

def write_error(self, status_code, **kwargs):
"""
from tornado.web import Finish, HTTPError
raise HTTPError(404)
raise HTTPError(404, reason="document not found")
raise HTTPError(404, None, {"id": "-1"}, reason="document not found") ->
{
"code": 404,
"success": False,
"error": "document not found"
"id": "-1"
}
"""

reason = kwargs.pop('reason', self._reason)
# "reason" is a reserved tornado keyword
Expand All @@ -204,7 +217,7 @@ def write_error(self, status_code, **kwargs):
}
try: # merge exception info
exception = kwargs['exc_info'][1]
message.update(exception.args[0])
message.update(exception.args[0]) # <-
except:
pass

Expand Down

0 comments on commit 7131379

Please sign in to comment.