| 125 | | elif settings.DEBUG: |
|---|
| 126 | | from django.views import debug |
|---|
| 127 | | return debug.technical_500_response(request, *exc_info) |
|---|
| 128 | | else: |
|---|
| 129 | | # When DEBUG is False, send an error message to the admins. |
|---|
| 130 | | subject = 'Error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS and 'internal' or 'EXTERNAL'), request.path) |
|---|
| 131 | | try: |
|---|
| 132 | | request_repr = repr(request) |
|---|
| 133 | | except: |
|---|
| 134 | | request_repr = "Request repr() unavailable" |
|---|
| 135 | | message = "%s\n\n%s" % (self._get_traceback(exc_info), request_repr) |
|---|
| 136 | | mail_admins(subject, message, fail_silently=True) |
|---|
| 137 | | # Return an HttpResponse that displays a friendly error message. |
|---|
| 138 | | callback, param_dict = resolver.resolve500() |
|---|
| 139 | | return callback(request, **param_dict) |
|---|
| | 124 | return self.handle_uncaught_exception(request, resolver, exc_info) |
|---|
| | 125 | |
|---|
| | 126 | def handle_uncaught_exception(self, request, resolver, exc_info): |
|---|
| | 127 | """ |
|---|
| | 128 | Processing for any otherwise uncaught exceptions (those that will |
|---|
| | 129 | generate HTTP 500 responses). Can be overridden by subclasses who want |
|---|
| | 130 | customised 500 handling. |
|---|
| | 131 | |
|---|
| | 132 | Be *very* careful when overriding this because the error could be |
|---|
| | 133 | caused by anything, so assuming something like the database is always |
|---|
| | 134 | available would be an error. |
|---|
| | 135 | """ |
|---|
| | 136 | from django.conf import settings |
|---|
| | 137 | from django.core.mail import mail_admins |
|---|
| | 138 | |
|---|
| | 139 | if settings.DEBUG: |
|---|
| | 140 | from django.views import debug |
|---|
| | 141 | return debug.technical_500_response(request, *exc_info) |
|---|
| | 142 | |
|---|
| | 143 | # When DEBUG is False, send an error message to the admins. |
|---|
| | 144 | subject = 'Error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS and 'internal' or 'EXTERNAL'), request.path) |
|---|
| | 145 | try: |
|---|
| | 146 | request_repr = repr(request) |
|---|
| | 147 | except: |
|---|
| | 148 | request_repr = "Request repr() unavailable" |
|---|
| | 149 | message = "%s\n\n%s" % (self._get_traceback(exc_info), request_repr) |
|---|
| | 150 | mail_admins(subject, message, fail_silently=True) |
|---|
| | 151 | # Return an HttpResponse that displays a friendly error message. |
|---|
| | 152 | callback, param_dict = resolver.resolve500() |
|---|
| | 153 | return callback(request, **param_dict) |
|---|