Ticket #13850: uncaught-exception-email.patch

File uncaught-exception-email.patch, 1.6 KB (added by Leonid Grinberg, 14 years ago)
  • base.py

     
    144144            # isolation of request.urlconf
    145145            urlresolvers.set_urlconf(None)
    146146
     147    def make_uncaught_exception_email(self, request, exc_info):
     148        subject = 'Error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS and 'internal' or 'EXTERNAL'), request.path)
     149        try:
     150            request_repr = repr(request)
     151        except:
     152            request_repr = "Request repr() unavailable"
     153        message = "%s\n\n%s" % (self._get_traceback(exc_info), request_repr)
     154        return subject, message
     155   
    147156    def handle_uncaught_exception(self, request, resolver, exc_info):
    148157        """
    149158        Processing for any otherwise uncaught exceptions (those that will
     
    165174            return debug.technical_500_response(request, *exc_info)
    166175
    167176        # When DEBUG is False, send an error message to the admins.
    168         subject = 'Error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS and 'internal' or 'EXTERNAL'), request.path)
    169         try:
    170             request_repr = repr(request)
    171         except:
    172             request_repr = "Request repr() unavailable"
    173         message = "%s\n\n%s" % (self._get_traceback(exc_info), request_repr)
     177        subject, message = self.make_uncaught_exception_email(request, exc_info)
    174178        mail_admins(subject, message, fail_silently=True)
    175179        # If Http500 handler is not installed, re-raise last exception
    176180        if resolver.urlconf_module is None:
Back to Top