Added generic 500 and 400 JSON error handlers.#5904
Merged
carltongibson merged 4 commits intoencode:masterfrom Apr 3, 2018
Merged
Added generic 500 and 400 JSON error handlers.#5904carltongibson merged 4 commits intoencode:masterfrom
carltongibson merged 4 commits intoencode:masterfrom
Conversation
|
|
||
| # Generic Error Views | ||
|
|
||
| Django REST Framework provides two error views suitable for providing generic JSON `500` Server Error and |
Contributor
There was a problem hiding this comment.
Great stuff! We might want to just outline the motivation here, ie “Django’s defaults give you HTML responses”
thomasw
reviewed
Aug 10, 2018
| Generic 500 error handler. | ||
| """ | ||
| data = { | ||
| 'error': 'Server Error (500)' |
There was a problem hiding this comment.
Would using detail as the key here have been more consistent with other DRF errors? I excitedly ripped out my own custom error handlers for DRF's shiny new ones only to see that the key for error details was now something unexpected.
pchiquet
pushed a commit
to pchiquet/django-rest-framework
that referenced
this pull request
Nov 17, 2020
* Added generic 500 and 400 JSON error handlers. * Docs for generic error views.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4556
Adds generic handlers for generic server error and bad request errors. (To be used with Django's
handler500andhandler400.)Unit tests on functions themselves but no integration tests, since the test client insists on re-raising any exceptions, rather than processing the error view.