diff options
| author | Tom Christie | 2012-09-16 14:02:18 -0700 |
|---|---|---|
| committer | Tom Christie | 2012-09-16 14:02:18 -0700 |
| commit | 549ebdc1c67c20bdff39a2f4a59012dd010213a1 (patch) | |
| tree | ef7b3626e602ecaa1761cb4e780501f0b8db9463 /djangorestframework/exceptions.py | |
| parent | b7b8cd11b1aad3fcf4bad221d164bb55e0bf5859 (diff) | |
| parent | d8ede0355c32455989ca5f955d555ffaf827b296 (diff) | |
| download | django-rest-framework-549ebdc1c67c20bdff39a2f4a59012dd010213a1.tar.bz2 | |
Merge pull request #263 from tomchristie/decouple-conneg
Content negotiation logic out of response and into View
Diffstat (limited to 'djangorestframework/exceptions.py')
| -rw-r--r-- | djangorestframework/exceptions.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/djangorestframework/exceptions.py b/djangorestframework/exceptions.py index 3f5b23f6..a405a885 100644 --- a/djangorestframework/exceptions.py +++ b/djangorestframework/exceptions.py @@ -31,6 +31,14 @@ class PermissionDenied(APIException): self.detail = detail or self.default_detail +class InvalidFormat(APIException): + status_code = status.HTTP_404_NOT_FOUND + default_detail = "Format suffix '.%s' not found." + + def __init__(self, format, detail=None): + self.detail = (detail or self.default_detail) % format + + class MethodNotAllowed(APIException): status_code = status.HTTP_405_METHOD_NOT_ALLOWED default_detail = "Method '%s' not allowed." @@ -39,6 +47,15 @@ class MethodNotAllowed(APIException): self.detail = (detail or self.default_detail) % method +class NotAcceptable(APIException): + status_code = status.HTTP_406_NOT_ACCEPTABLE + default_detail = "Could not satisfy the request's Accept header" + + def __init__(self, detail=None, available_renderers=None): + self.detail = detail or self.default_detail + self.available_renderers = available_renderers + + class UnsupportedMediaType(APIException): status_code = status.HTTP_415_UNSUPPORTED_MEDIA_TYPE default_detail = "Unsupported media type '%s' in request." |
