Opened 10 years ago
Last modified 5 years ago
#24619 closed New feature
Technical error responses (404 and 500) should return responses dependent on Accept header — at Initial Version
Reported by: | Marcin Nowak | Owned by: | nobody |
---|---|---|---|
Component: | Error reporting | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Technical error responses are used in DEBUG mode only and they aren't customizable.
In most cases they are resulting HTML output, but plain text only for AJAX-like requests (based on request.is_ajax()
return value).
As a developer who is creating views/services non HTML-related (JSON, XML, etc as a response) I have huge problems with reading output from technical responses when error occurs. I'm getting in my console or shell HTML mixed with Javascript and CSS, which is hard to read. Text output from technical responses is hard-readable too, but better than HTML.
Technical responses should use some sort of output renderers registry based on Accept
header. They should implement or use content type negotiation strategy and match against available renderers. Current HTML and text output can be mapped for text/html
and text/plain
types respectively. Also as a developer I need to extend registry of supported content types for my specific needs. For example - I need error 500 technical response returned as application/json
content-type. Django can provide some builtin technical output renderes.
Optionally content-type negotiation functionality can be built as a standalone helper for common use.
Extracted from #24610