aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Freeland2013-09-06 13:57:32 -0500
committerAndy Freeland2013-09-06 13:57:32 -0500
commitbae0ef6b5dcb0abf2be865340e5476aeab5ce137 (patch)
treefdda0ce33b578f9844d4768377fe6ddddd3b0b66
parentb5523bcc7ddab97620fd7b49e385b44c664ca899 (diff)
downloaddjango-rest-framework-bae0ef6b5dcb0abf2be865340e5476aeab5ce137.tar.bz2
Add EXCEPTION_HANDLER docs to exception docs
-rw-r--r--docs/api-guide/exceptions.md20
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