I have this middelware which is suppose to catch 500/400 exceptions and deal with them. But it never gets called. I've put it in the beginning and end of the MIDDLEWARE_CLASSES
but it still doesn't run when an exception is raised:
vertical/middleware.py:
class HandleExceptionsMiddleware(object):
def process_exception(self, request, exception):
print >> sys.stderr, "exception has been raised"
# Get the exception info now, in case another exception is thrown later.
if isinstance(exception, http.Http404):
return self.handle_404(request, exception)
else:
return self.handle_500(request, exception)
settings.py
MIDDLEWARE_CLASSES = (
'vertical.middleware.HandleExceptionsMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)