<s> from django . conf import settings <EOL> from django . core . exceptions import MiddlewareNotUsed <EOL> from django . http import HttpResponse <EOL> class AjaxTracebackMiddleware ( object ) : <EOL> def __init__ ( self ) : <EOL> if not settings . DEBUG : <EOL> raise MiddlewareNotUsed <EOL> def process_exception ( self , request , * args , ** kwargs ) : <EOL> if request . is_ajax ( ) : <EOL> import traceback <EOL> return HttpResponse ( traceback . format_exc ( ) . replace ( "<STR_LIT:\n>" , "<STR_LIT>" ) ) </s>
