from django.conf import settings
from django.http import HttpResponseServerError
class AJAXSimpleExceptionResponse:
def process_exception(self, request, exception):
if settings.DEBUG:
if request.META.get('HTTP_X_REQUESTED_WITH', None) == 'XMLHttpRequest':
import sys, traceback
(exc_type, exc_info, tb) = sys.exc_info()
response = "%s\n" % exc_type.__name__
response += "%s\n\n" % exc_info
response += "TRACEBACK:\n"
for tb in traceback.format_tb(tb):
response += "%s\n" % tb
return HttpResponseServerError(response)
Comments
Nice idea - thanks!
#
This will be great. Although I have gotten good at finding the exception in the source of the pretty error pages :)
#
Works great. Thanks!
#
You can also document.write() on 500 in the javascript to display the error instead of trying to read it in firebug.
#
I use it, too.
I use the Poster firefox add-on for a lot of Ajax-Debugging, but it seems buggy for HTTP_ACCEPT headers.
Thanks.
#