Running django 1.3. If I have an unhandled exception in a view, e.g.
def test(request):
raise Exception('error')
GETing the page (here via wget):
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `index.html'
[ <=> ] 218 --.-K/s in 0s
2011-08-04 17:47:43 (14.9 MB/s) - `index.html' saved [218]
Contents of index.html:
<!D开发者_Python百科OCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>Unhandled Exception</title>
</head><body>
<h1>Unhandled Exception</h1>
<p>An unhandled exception was thrown by the application.</p>
</body></html>
And now to the question: why is the response status code 200? It should be 500.
EDIT: Run on lighttpd with command
manage.py runfcgi --settings=$SETTINGS socket=$SOCKET pidfile=$PIDFILE method=prefork minspare=1 maxspare=1 maxchildren=10 maxrequests=100"
DEBUG=FALSE in settings.py. If I change to DEBUG=TRUE, the response status code is correctly 500.
With DEBUG = False
it will try to run the 500.html
template. Have you created that file?
精彩评论