diff options
| author | Tom Christie | 2013-12-23 12:37:56 +0000 | 
|---|---|---|
| committer | Tom Christie | 2013-12-23 12:37:56 +0000 | 
| commit | 66cc2d3d5d611c57638a59932cd65c62d9b130c2 (patch) | |
| tree | 9856f0c766c51f45e753dd8a6c01844879c5c0b4 /api-guide/exceptions.html | |
| parent | e6fd79fd88067d830886f9c463d5b9e5c13d7ce3 (diff) | |
| download | django-rest-framework-66cc2d3d5d611c57638a59932cd65c62d9b130c2.tar.bz2 | |
Switch title ordering.
Diffstat (limited to 'api-guide/exceptions.html')
| -rw-r--r-- | api-guide/exceptions.html | 9 | 
1 files changed, 8 insertions, 1 deletions
| diff --git a/api-guide/exceptions.html b/api-guide/exceptions.html index 161a69e1..c83a6a6d 100644 --- a/api-guide/exceptions.html +++ b/api-guide/exceptions.html @@ -2,7 +2,7 @@  <html lang="en">  <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">      <meta charset="utf-8"> -    <title>Django REST framework - Exceptions</title> +    <title>Exceptions - Django REST framework</title>      <link href="http://django-rest-framework.org/img/favicon.ico" rel="icon" type="image/x-icon">      <link rel="canonical" href="http://django-rest-framework.org/api-guide/exceptions"/>      <meta name="viewport" content="width=device-width, initial-scale=1.0"> @@ -279,6 +279,13 @@ def custom_exception_handler(exc):  <p><strong>Signature:</strong> <code>APIException()</code></p>  <p>The <strong>base class</strong> for all exceptions raised inside REST framework.</p>  <p>To provide a custom exception, subclass <code>APIException</code> and set the <code>.status_code</code> and <code>.detail</code> properties on the class.</p> +<p>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:</p> +<pre class="prettyprint lang-py"><code>from rest_framework.exceptions import APIException + +class ServiceUnavailable(APIException): +    status_code = 503 +    detail = 'Service temporarily unavailable, try again later.' +</code></pre>  <h2 id="parseerror">ParseError</h2>  <p><strong>Signature:</strong> <code>ParseError(detail=None)</code></p>  <p>Raised if the request contains malformed data when accessing <code>request.DATA</code> or <code>request.FILES</code>.</p> | 
