Hi Tom

Thanks for your email.

On May 16, 4:14 pm, Tom Evans <tevans...@googlemail.com> wrote:
> On Wed, May 16, 2012 at 12:32 PM, Rory Campbell-Lange
>
> <r...@campbell-lange.net> wrote:

> > I have a view raising a specific exception I would like to catch and
> > provide an HttpResponse based on this exception.
>
> If it is one view raising one specific exception, why aren't you
> catching it in that view? Exception middleware is used to provide a
> more generic error page, or for advanced error handling, or to handle
> errors from a number of views. If it is just for one view, one
> exception, it is more coherent to handle the error in the view.

As noted before in this thread I have a lazy rowgetter that only
triggers an exception
 in the template. In other words, the except clause in my view isn't
triggered.

    try:
        rota = self.model.xmlapi_get_location (**kwargs)
    except DBException, e:
        code, message = [epart.strip() for epart in e.msg.split(':')]
        return HttpResponse(message, status=code,
                            content_type="text/plain")

> > My middleware is as follows -- its simply a sketch at present:
>
> >    class ExceptCatcher(object):
> >        def process_exception(self, request, exception):
> >            HttpResponse("Error encountered")
>
> Is this code verbatim? If so, you aren't returning the newly generated
> HttpResponse, just creating it.

I'm simply trying to trigger the exception handler in ipdb and that is
not happening
using either either the standard middleware or
decorator_from_middleware
methodologies. I guess this might be because control has passed from
the view?
decorators.py:handle_uncaught_exception _is_ called, but I am unable
to interject my
ExceptCatcher with it.

> These sorts of questions should be on django-users really.

Sorry if this is the wrong place to post. However there are a number
of people on the
web reporting that they are unable to trigger process_exception. Hence
my query here.


-- 
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 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to