--- base.py (revision 3393)
+++ base.py (revision 3596)
@@ -1,7 +1,8 @@
from django.utils import httpwrappers
+import sys
class BaseHandler:
def __init__(self):
self._request_middleware = self._view_middleware = self._response_middleware = self._exception_middleware = None
def load_middleware(self):
@@ -105,18 +106,19 @@
except exceptions.PermissionDenied:
return httpwrappers.HttpResponseForbidden('
Permission denied
')
except: # Handle everything else, including SuspiciousOperation, etc.
if DEBUG:
return self.get_technical_error_response(request)
else:
+ exc_info = sys.exc_info()
subject = 'Coding error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in INTERNAL_IPS and 'internal' or 'EXTERNAL'), getattr(request, 'path', ''))
try:
request_repr = repr(request)
except:
request_repr = "Request repr() unavailable"
- message = "%s\n\n%s" % (self._get_traceback(), request_repr)
+ message = "%s\n\n%s" % (self._get_traceback(exc_info), request_repr)
mail_admins(subject, message, fail_silently=True)
return self.get_friendly_error_response(request, resolver)
def get_friendly_error_response(self, request, resolver):
"""
Returns an HttpResponse that displays a PUBLIC error message for a
@@ -135,10 +137,10 @@
from django.views import debug
if is404:
return debug.technical_404_response(request, exception)
else:
return debug.technical_500_response(request, *sys.exc_info())
- def _get_traceback(self):
+ def _get_traceback(self, exc_info=None):
"Helper function to return the traceback as a string"
import sys, traceback
- return '\n'.join(traceback.format_exception(*sys.exc_info()))
+ return '\n'.join(traceback.format_exception(*(exc_info or sys.exc_info())))