diff options
| author | Tom Christie | 2013-09-07 12:12:23 -0700 | 
|---|---|---|
| committer | Tom Christie | 2013-09-07 12:12:23 -0700 | 
| commit | 6908c183a4331494c60c4aa025003a544bb4d15c (patch) | |
| tree | fdda0ce33b578f9844d4768377fe6ddddd3b0b66 /docs/api-guide/exceptions.md | |
| parent | 916d8ab37da2f0c4412507710649ba0f352f29bb (diff) | |
| parent | bae0ef6b5dcb0abf2be865340e5476aeab5ce137 (diff) | |
| download | django-rest-framework-6908c183a4331494c60c4aa025003a544bb4d15c.tar.bz2 | |
Merge pull request #1092 from rouge8/custom-exception-handler-setting
Support customizable view EXCEPTION_HANDLER (#907)
Diffstat (limited to 'docs/api-guide/exceptions.md')
| -rw-r--r-- | docs/api-guide/exceptions.md | 20 | 
1 files changed, 19 insertions, 1 deletions
| diff --git a/docs/api-guide/exceptions.md b/docs/api-guide/exceptions.md index 8b3e50f1..fa5053df 100644 --- a/docs/api-guide/exceptions.md +++ b/docs/api-guide/exceptions.md @@ -30,9 +30,27 @@ Might receive an error response indicating that the `DELETE` method is not allow      HTTP/1.1 405 Method Not Allowed      Content-Type: application/json; charset=utf-8      Content-Length: 42 -     +      {"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 | 
