提交 cfb8b809 编写于 作者: E Evan Klitzke

add text tracebacks on 500s when in debug mode

上级 3486b46f
......@@ -70,6 +70,7 @@ import stat
import sys
import time
import tornado
import traceback
import types
import urllib
import urlparse
......@@ -663,11 +664,16 @@ class RequestHandler(object):
If this error was caused by an uncaught exception, the
exception object can be found in kwargs e.g. kwargs['exception']
"""
return "<html><title>%(code)d: %(message)s</title>" \
"<body>%(code)d: %(message)s</body></html>" % {
"code": status_code,
"message": httplib.responses[status_code],
}
if self.settings.get("debug"):
# in debug mode, try to send a traceback
self.set_header('Content-Type', 'text/plain')
return traceback.format_exc()
else:
return "<html><title>%(code)d: %(message)s</title>" \
"<body>%(code)d: %(message)s</body></html>" % {
"code": status_code,
"message": httplib.responses[status_code],
}
@property
def locale(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册