#NEWLINE# def process_exception( self , request , exception ) : #NEWLINE# #INDENT# if request . is_ajax ( ) : #NEWLINE# #INDENT# ( exc_type , exc_info , tb ) = sys . exc_info ( ) #NEWLINE# response = ( '%s: ' % exc_type . __name__ ) #NEWLINE# response += ( '%s' % exc_info ) #NEWLINE# msg = 'AjaxExceptionResponse {0}\n' . format ( response ) #NEWLINE# msg += '\nin request {0}\n' . format ( format_request ( request ) ) #NEWLINE# msg += 'TRACEBACK:\n' #NEWLINE# for tb in traceback . format_tb ( tb ) : #NEWLINE# #INDENT# msg += smart_text ( tb ) #NEWLINE# #UNINDENT# if settings . DEBUG : #NEWLINE# #INDENT# settings . SITE . logger . warning ( msg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# settings . SITE . logger . exception ( msg ) #NEWLINE# #UNINDENT# if isinstance ( exception , PermissionDenied ) : #NEWLINE# #INDENT# return HttpResponseForbidden ( response ) #NEWLINE# #UNINDENT# if isinstance ( exception , ObjectDoesNotExist ) : #NEWLINE# #INDENT# return HttpResponseBadRequest ( response ) #NEWLINE# #UNINDENT# return HttpResponseServerError ( response )