From: Evan Klitzke Date: Thu, 23 Jun 2011 18:14:16 +0000 (-0700) Subject: add text tracebacks on 500s when in debug mode X-Git-Tag: v2.1.0~133^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cfb8b809c1bdd814ce211d9a5dc409e7b6013960;p=thirdparty%2Ftornado.git add text tracebacks on 500s when in debug mode --- diff --git a/tornado/web.py b/tornado/web.py index 55989468e..f0a8d2d5c 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -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 "%(code)d: %(message)s" \ - "%(code)d: %(message)s" % { - "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 "%(code)d: %(message)s" \ + "%(code)d: %(message)s" % { + "code": status_code, + "message": httplib.responses[status_code], + } @property def locale(self):