aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/exceptions.md
diff options
context:
space:
mode:
authorTom Christie2013-12-23 09:48:59 +0000
committerTom Christie2013-12-23 09:48:59 +0000
commit52686420f4bf866064ee88a15903665f14289394 (patch)
tree41ea7b0d4863092f996f63de14e678a1c74a7a3a /docs/api-guide/exceptions.md
parent9c41c007afc71c899306bcb02e40bdfc36b09146 (diff)
parent83b31e7ea298a8948e9a76c9b971845ea0052b3c (diff)
downloaddjango-rest-framework-52686420f4bf866064ee88a15903665f14289394.tar.bz2
Merge branch 'bennbollay-patch-1' into 2.4.0
Conflicts: .travis.yml docs/api-guide/routers.md rest_framework/compat.py tox.ini
Diffstat (limited to 'docs/api-guide/exceptions.md')
-rw-r--r--docs/api-guide/exceptions.md8
1 files changed, 8 insertions, 0 deletions
diff --git a/docs/api-guide/exceptions.md b/docs/api-guide/exceptions.md
index c46d415e..221df679 100644
--- a/docs/api-guide/exceptions.md
+++ b/docs/api-guide/exceptions.md
@@ -88,6 +88,14 @@ The **base class** for all exceptions raised inside REST framework.
To provide a custom exception, subclass `APIException` and set the `.status_code` and `.detail` properties on the class.
+For example, if your API relies on a third party service that may sometimes be unreachable, you might want to implement an exception for the "503 Service Unavailable" HTTP response code. You could do this like so:
+
+ from rest_framework.exceptions import APIException
+
+ class ServiceUnavailable(APIException):
+ status_code = 503
+ detail = 'Service temporarily unavailable, try again later.'
+
## ParseError
**Signature:** `ParseError(detail=None)`