You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api-guide/exceptions.md
+19-1Lines changed: 19 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -30,9 +30,27 @@ Might receive an error response indicating that the `DELETE` method is not allow
30
30
HTTP/1.1 405 Method Not Allowed
31
31
Content-Type: application/json; charset=utf-8
32
32
Content-Length: 42
33
-
33
+
34
34
{"detail": "Method 'DELETE' not allowed."}
35
35
36
+
## Custom exception handling
37
+
38
+
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:
39
+
40
+
exception_handler(exc)
41
+
42
+
*`exc`: The exception.
43
+
44
+
If the function returns `None`, a 500 error will be raised.
45
+
46
+
The exception handler is set globally, using the `EXCEPTION_HANDLER` setting. For example:
0 commit comments