Hi - thanks for your responses.  Was on vacation and forgot to check
back on this thread.  The idea of middleware is good.  I'm not sure,
however, if the views.py code generates an exception, that it can be
caught by the middleware?  I guess the question is how to catch
exceptions.  The views.py code is invoked by the django code, so on a
normal request, that django code must catch the exception and then
send it as a response to the client.  On a non-ajax request, the
response just gets displayed in the browser.  But on an ajax request,
unless I do some special stuff, I guess that response doesn't get
displayed.  So the question becomes how to catch the exception and put
it somewhere useful, and I'm still not clear if I can use middleware
to do that.

One thing that I realize is that if I just make a request to the same
address that the ajax request is going to, then I do see the error
trace in my browser, so that's helpful and that's the tact I have been
taking lately.

Margie

On Feb 12, 2:33 am, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On Feb 11, 10:27 pm, MargieRoginski<margierogin...@yahoo.com> wrote:
>
> > I have a question about debugging django server side code in the case
> > where the request is an ajax request.
>
> From the server-side POV, a request is a request is a request. Truth
> is : there's no such thing as an "ajax request".
>
> >  For example I have an
> > autocomplete widget.  It makes a request to a particular url that
> > takes me to one of my views.py functions, get_users(request).  If I
> > have some sort of error in that function, I don't see the error
> > anywhere and it just silently fails.
>
> It's your client code that fails to handle the case properly.
>
> >  If I explicitly put that url
> > into the address bar then the error comes up in my browser, or if I
> > use pdb to put a break point and then step through my code, I see the
> > error.   In the case of an ajax request,
>
> cf above.
>
> > what happens to the error
> > from the server code and is there any way to see it?
>
> yes : look at the response content. Firebug is your friend - it lets
> you trace and inspect XMLHttpRequests and their responses. Also, you
> may want to have a "logging" middleware that logs unhandled errors -
> this is useful both in dev or in production.
>
> HTH

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

Reply via email to