mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +03:00
Add EXCEPTION_HANDLER docs to exception docs
This commit is contained in:
parent
b5523bcc7d
commit
bae0ef6b5d
|
@ -33,6 +33,24 @@ Might receive an error response indicating that the `DELETE` method is not allow
|
|||
|
||||
{"detail": "Method 'DELETE' not allowed."}
|
||||
|
||||
## Custom exception handling
|
||||
|
||||
To implement custom exception handling (e.g. to handle additional exception classes or to override the error response format), create an exception handler function with the following signature:
|
||||
|
||||
exception_handler(exc)
|
||||
|
||||
* `exc`: The exception.
|
||||
|
||||
If the function returns `None`, a 500 error will be raised.
|
||||
|
||||
The exception handler is set globally, using the `EXCEPTION_HANDLER` setting. For example:
|
||||
|
||||
'EXCEPTION_HANDLER': 'project.app.module.function'
|
||||
|
||||
If not specified, this setting defaults to the exception handler described above:
|
||||
|
||||
'EXCEPTION_HANDLER': 'rest_framework.views.exception_handler'
|
||||
|
||||
---
|
||||
|
||||
# API Reference
|
||||
|
|
Loading…
Reference in New Issue
Block a user