There are two options I can think of on an unmodified Django install.
Firstly, write a middleware that implements process_exception(). This
middleware will get invoked whenever an exception is raised as part of
the view; the middleware method will be the exception as one of the
arguments.
http://docs.djangoproject.com/en/dev/topics/http/middleware/#process-exception
Secondly, write a listener for the got_request_exception signal. This
signal is fired whenever an exception other than 404, Permission
Denied, or SystemExit is raised.
http://docs.djangoproject.com/en/dev/ref/signals/#django.core.signals.got_request_exception
> For an optimistic moment I thought ``--traceback`` was a bit
> promising, but then it turned out that it doesn't really seem to do
> what I expected in the case of ``runserver``. I even considered
> switching to e-mail tracebacks but ended up writing a client to mimic
> the 3rd party tool's functionality instead.
When I read this I went and had a look at the code, and it appears you
are correct. ``--traceback`` exists as a top-level command option, but
it doesn't appear to be exploited at all in runserver. This actually
surprised me - it seems like a reasonable suggestion for an
improvement. Feel free to open this as a ticket (and if you're really
adventurous, work on a patch :-)
Yours,
Russ Magee %-)
This isn't entirely surprising. Between 0.96 and 1.0, manage.py
received a major refactor. Unfortunately, the command line behavior of
django-admin is one of those things that is very difficult to unit
test, so it is quite easy for mistakes like this to slip in
accidentally.
If you're particularly enthused by the historical reasoning, you could
search the Subversion history to find the revision at which the
feature disappeared. 0.96 was tagged at r4810, so anywhere between
there and now (r9772 as I write this) could be the cause. With a
binary search, you should be able to find the offending revision in
about a dozen steps.
>> > For an optimistic moment I thought ``--traceback`` was a bit
>> > promising, but then it turned out that it doesn't really seem to do
>> > what I expected in the case of ``runserver``. I even considered
>> > switching to e-mail tracebacks but ended up writing a client to mimic
>> > the 3rd party tool's functionality instead.
>>
>> When I read this I went and had a look at the code, and it appears you
>> are correct. ``--traceback`` exists as a top-level command option, but
>> it doesn't appear to be exploited at all inrunserver. This actually
>> surprised me - it seems like a reasonable suggestion for an
>> improvement. Feel free to open this as a ticket (and if you're really
>> adventurous, work on a patch :-)
>
> I can open a ticket, and even attempt a patch. How did this go away?
> I'm curious.
Magic elves. They conspired with the fairies :-)
Seriously, I have no idea. I can't think of any reason it would be
deliberate. Regardless of the cause, it would be nice to have this
feature restored. Any patch would be gratefully accepted.
Yours
Russ Magee %-)