﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
6094	core handlers do not catch middleware exceptions	Gary Wilson	Gary Wilson	"This causes bare exceptions to be returned.  To reproduce, just put a `raise Exception` statement in the `process_request` method of a middleware you are using.  You will get a traceback like this in your browser:

{{{
Traceback (most recent call last):

  File ""/home/gdub/bzr/django/upstream/django/core/servers/basehttp.py"", line 277, in run
    self.result = application(self.environ, self.start_response)

  File ""/home/gdub/bzr/django/upstream/django/core/servers/basehttp.py"", line 619, in __call__
    return self.application(environ, start_response)

  File ""/home/gdub/bzr/django/upstream/django/core/handlers/wsgi.py"", line 205, in __call__
    response = self.get_response(request)

  File ""/home/gdub/bzr/django/upstream/django/core/handlers/base.py"", line 63, in get_response
    response = middleware_method(request)

  File ""/home/gdub/bzr/django/upstream/django/middleware/common.py"", line 29, in process_request
    raise Exception

Exception
}}}

If you put a `raise Exception` statement in the `process_response` method of a middleware you are using, then you will get a traceback like this in your browser:

{{{
Traceback (most recent call last):

  File ""/home/gdub/bzr/django/upstream/django/core/servers/basehttp.py"", line 277, in run
    self.result = application(self.environ, self.start_response)

  File ""/home/gdub/bzr/django/upstream/django/core/servers/basehttp.py"", line 619, in __call__
    return self.application(environ, start_response)

  File ""/home/gdub/bzr/django/upstream/django/core/handlers/wsgi.py"", line 209, in __call__
    response = middleware_method(request, response)

  File ""/home/gdub/bzr/django/upstream/django/middleware/common.py"", line 62, in process_response
    raise Exception

Exception
}}}

WSGI and ModPython handlers are both affected.

Discussion: http://groups.google.com/group/django-developers/browse_thread/thread/255b42846c7e49e9

I would think that we want these exceptions to be handled by the standard exception handling.  Should they also be passed through `process_exception` middlewares?  Currently only exceptions raised in views get passed through `process_exception` middlewares."		closed	HTTP handling	dev		fixed		jdunck@… cmawebsite@… gav@… Trevor Caira mpjung@… me@… Maniac@… sdeasey@… Carl Meyer Gonzalo Saavedra Gert Van Gool Andrey Golovizin	Accepted	1	0	0	0	0	0
