Commit 49226fbf by Sheng

Swallow 500 errors

parent ad12876b
...@@ -74,13 +74,15 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler): ...@@ -74,13 +74,15 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
self.result = dict(id=None, status=None, encoding=None) self.result = dict(id=None, status=None, encoding=None)
def write_error(self, status_code, **kwargs): def write_error(self, status_code, **kwargs):
if self.settings.get('serve_traceback') or status_code == 500 or \ if not swallow_http_errors:
not swallow_http_errors:
super(MixinHandler, self).write_error(status_code, **kwargs) super(MixinHandler, self).write_error(status_code, **kwargs)
else: else:
exc_info = kwargs.get('exc_info') if status_code == 500:
if exc_info: self._reason = 'Internal Server Error'
self._reason = exc_info[1].log_message else:
exc_info = kwargs.get('exc_info')
if exc_info:
self._reason = exc_info[1].log_message
self.result.update(status=self._reason) self.result.update(status=self._reason)
self.set_status(200) self.set_status(200)
self.finish(self.result) self.finish(self.result)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment