1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | from django.conf import settings
from django.http import HttpResponseServerError
class AJAXSimpleExceptionResponse:
def process_exception(self, request, exception):
if settings.DEBUG:
if request.is_ajax():
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)
|
More like this
- Middleware for printing of exception to console by dballanc 4 years, 8 months ago
- another render_to_response wrapper by ro60 4 years, 4 months ago
- Super User Conditional Page Exception Reporting by zbyte64 3 years, 9 months ago
- Fetching list of SQL queries executed so far for all requests by hiddentao 5 months, 1 week ago
- AjaxCheckMiddleware by kylefox 4 years, 3 months ago
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.
#
very nice article. [url=http://www.tupbebegim.org ]tüp bebek merkezleri[/url] tüp bebek raporu ve tadavisi
ankara nakliyat evden eve nakliyat [HTML_REMOVED]ankara nakliyat[HTML_REMOVED]
#
I always detect in my Javascript if the response holds HTML. If it does, I create a floating iframe and pass it the response. That way you can fold/unfold the stack source and use the debug page as usual.
Simon.
#
Is it works with dev(trunk) of django?
I copy code to utils/middleware.py and add line to settings.py:
but I don't see any changes in ajax exceptions output..
#