Login

Middleware for printing of exception to console

Author:
dballanc
Posted:
September 18, 2007
Language:
Python
Version:
.96
Tags:
middleware console exception
Score:
4 (after 4 ratings)

The django debug screens are great, but only when you can see them. Trying to debug javascript/ajax calls can be kind of a pain. This just a copy/paste of some code in django's internals stuck in a middleware so that exceptions also print to the dev server console.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
class ConsoleExceptionMiddleware:
    def process_exception(self, request, exception):
        import traceback
        import sys
        exc_info = sys.exc_info()
        print "######################## Exception #############################"
        print '\n'.join(traceback.format_exception(*(exc_info or sys.exc_info())))
        print "################################################################"
        #print repr(request)
        #print "################################################################"

More like this

  1. Print Exceptions to the Console by ericflo 5 years, 7 months ago
  2. SQL Log To Console Middleware by davepeck 5 years, 6 months ago
  3. Output sql_queries in Firebug console when in debug mode by wojas 4 years, 11 months ago
  4. middleware to capture doesnot exists exception by vbachu 1 year, 7 months ago
  5. SQL Printing Middleware by ericflo 7 years, 8 months ago

Comments

Please login first before commenting.