#22621: Return JSON response in default error handlers for ajax requests
-------------------------------+--------------------------------------
     Reporter:  Tomáš Ehrlich  |                    Owner:  nobody
         Type:  New feature    |                   Status:  closed
    Component:  Core (URLs)    |                  Version:  dev
     Severity:  Normal         |               Resolution:  wontfix
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

Comment (by Alan Justino da Silva):

 Replying to [comment:2 Sasha Romijn]:
 > We might be talking about the two different mutually exclusive 500 views
 in Django. As Tim's example includes the exception, that sounds like a
 debug view.

 Please correct me, but doing `str()` over an Exception returns only the
 error name/details, not the full traceback. That is what I would expect as
 a 500 on JSON, exactly the same as a 500 on HTML.

 > What would you do with these values? When is it not enough to just look
 at the 500 response code?

 I expect JSON client callers to be able to parse the answers in JSON when
 providing `Accept: application/json`, even if the call errors out.

 > Also remember that Tim's example would not be acceptable in non-debug
 mode (as default built-in Django view), because we don't want to provide
 details on the exception in the output.

 That is fair. What about providing only the same of HTML "Server Error
 (500)" but in a JSON wrap instead of a HTML wrap?

 > So, adding this to the code is simple, but I do not understand what
 problem you are trying to solve. Until that is clarified, I'm closing as
 wontfix.

 The problem is about a client asking for `Accept: application/json` not
 expecting to handle anything but JSON, and the 500 response being HTML
 even for a request with `Accept: application/json`.

 That said, would you reconsider the `wontfix` solution?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22621#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018c1190286a-23e54842-f6be-4efa-9b2c-05f6069dbe5e-000000%40eu-central-1.amazonses.com.

Reply via email to