Skip to content

Commit

Permalink
magic-removal: Merged to [2668]
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2669 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Apr 11, 2006
1 parent 5cb59be commit a3f8ab3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions django/core/handlers/base.py
@@ -1,6 +1,7 @@
from django.core import signals
from django.dispatch import dispatcher
from django import http
import sys

class BaseHandler:
def __init__(self):
Expand Down Expand Up @@ -98,14 +99,16 @@ def get_response(self, path, request):
if settings.DEBUG:
return self.get_technical_error_response(request)
else:
# Get the exception info now, in case another exception is thrown later.
exc_info = sys.exc_info()
receivers = dispatcher.send(signal=signals.got_request_exception)
# When DEBUG is False, send an error message to the admins.
subject = 'Error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in settings.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)

Expand All @@ -123,14 +126,13 @@ def get_technical_error_response(self, request, is404=False, exception=None):
Returns an HttpResponse that displays a TECHNICAL error message for a
fundamental error.
"""
import sys
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()))
import traceback
return '\n'.join(traceback.format_exception(*(exc_info or sys.exc_info())))

0 comments on commit a3f8ab3

Please sign in to comment.