diff options
| author | Tom Christie | 2013-12-21 21:10:05 +0000 | 
|---|---|---|
| committer | Tom Christie | 2013-12-21 21:10:05 +0000 | 
| commit | bc0e994784f46330b4e849c3326fbd5c500298b3 (patch) | |
| tree | 4e29a19c3cd5efc17bee3e05c460170f39b8d424 /docs/api-guide/exceptions.md | |
| parent | 1f3ded4559ad18d03ee49b3befd19ddaea7e70b2 (diff) | |
| download | django-rest-framework-bc0e994784f46330b4e849c3326fbd5c500298b3.tar.bz2 | |
Added example of using APIException class.  Closes #1300
Diffstat (limited to 'docs/api-guide/exceptions.md')
| -rw-r--r-- | docs/api-guide/exceptions.md | 8 | 
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)` | 
