mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 04:20:12 +03:00
Docs for generic error views.
This commit is contained in:
parent
51760a6ed8
commit
2f9d854048
|
@ -230,5 +230,32 @@ The generic views use the `raise_exception=True` flag, which means that you can
|
||||||
|
|
||||||
By default this exception results in a response with the HTTP status code "400 Bad Request".
|
By default this exception results in a response with the HTTP status code "400 Bad Request".
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Generic Error Views
|
||||||
|
|
||||||
|
Django REST Framework provides two error views suitable for providing generic JSON `500` Server Error and
|
||||||
|
`400` Bad Request responses.
|
||||||
|
|
||||||
|
Use these as per [Django's Customizing error views documentation][django-custom-error-views].
|
||||||
|
|
||||||
|
## `rest_framework.exceptions.server_error`
|
||||||
|
|
||||||
|
Returns a response with status code `500` and `application/json` content type.
|
||||||
|
|
||||||
|
Set as `handler500`:
|
||||||
|
|
||||||
|
handler500 = 'rest_framework.exceptions.server_error'
|
||||||
|
|
||||||
|
## `rest_framework.exceptions.server_error`
|
||||||
|
|
||||||
|
Returns a response with status code `400` and `application/json` content type.
|
||||||
|
|
||||||
|
Set as `handler400`:
|
||||||
|
|
||||||
|
handler400 = 'rest_framework.exceptions.bad_request'
|
||||||
|
|
||||||
[cite]: https://doughellmann.com/blog/2009/06/19/python-exception-handling-techniques/
|
[cite]: https://doughellmann.com/blog/2009/06/19/python-exception-handling-techniques/
|
||||||
[authentication]: authentication.md
|
[authentication]: authentication.md
|
||||||
|
[django-custom-error-views]: https://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views
|
||||||
|
|
Loading…
Reference in New Issue
Block a user