On Sat, Dec 27, 2008 at 2:32 AM, Fridrik Mar Jonsson <[email protected]> wrote: > > Hi Djangonians, > > I recently had an instance where it would have been really convenient > to see the error and a traceback in the ``runserver`` console instead > of just a single line telling me that the request returned a 500 > error. > > In the event of blind debugging, where a 3rd party tool is performing > a request that renders in an error, is there a Django mechanism or > extension that allows you to catch any exceptions that occur during a > page load and redirect them to the ``runserver`` console in addition > to displaying them in the template?
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 %-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

