I have a use case in which I need an exception middleware to do
something custom, but would just like to annotate the response
provided by Django's normal request exception handling.

I see the exception handling code is fairly intricate, but I'm
thinking about working up a patch that would (attempt) to make the
exception handling code reusable.

Of course, Django would still have the final exception handling clause
to provide a fallback from any earlier attempt at handling the
exception.

At first glance, this would involve making a method that takes e and
sys.exc_info as parameters and returns a response.

The final result would be that the exception clauses in Django would
be a method, reducing the exception clause in the base handler to
calling that method.

The benefit is that then, exception middleware can do something like this:

=================
from django.core.handlers import handle_exception
...
def process_exception(self, request, exception):
    response = handle_exception(request, exception)
    response['X-Magic'] = 'tada'
    return response

=================

I think this keeps the exception handling semantics the same, but
provides a hook for further handling the exception.  Coincidentally,
it makes request exception handling look a lot like a view...

Thoughts?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to