﻿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
2481	Exceptions thrown by request middleware are not caught	Simon Willison	nobody	"At the moment, an exception thrown by request middleware is not caught by Django's exception handling middleware, and can result in an ugly Apache default 500 error screen. This also means that you can't throw an Http404 exception in request middleware, which is annoying as an obvious use for it is to apply additional URL filtering or blocking.

My particular use case is throwing a 404 for unknown subdomains while using wildcard DNS. At the moment I'm having to use view middleware for this instead to ensure the 404 gets caught.

Is there a reason that request middleware is executed outside the main try/catch block, or could it be moved in there without breaking anything?

Here's [http://code.djangoproject.com/browser/django/trunk/django/core/handlers/base.py?rev=3411#L57 the code in question]."	defect	closed	Core (Other)		minor	duplicate			Accepted	0	0	0	0	0	0
