aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'djangorestframework/exceptions.py')
-rw-r--r--djangorestframework/exceptions.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/djangorestframework/exceptions.py b/djangorestframework/exceptions.py
index b29d96ba..3f7e9029 100644
--- a/djangorestframework/exceptions.py
+++ b/djangorestframework/exceptions.py
@@ -17,12 +17,20 @@ class PermissionDenied(Exception):
self.detail = detail or self.default_detail
+class MethodNotAllowed(Exception):
+ status_code = status.HTTP_405_METHOD_NOT_ALLOWED
+ default_detail = "Method '%s' not allowed"
+
+ def __init__(self, method, detail):
+ self.detail = (detail or self.default_detail) % method
+
+
class UnsupportedMediaType(Exception):
- status_code = 415
- default_detail = 'Unsupported media type in request'
+ status_code = status.HTTP_415_UNSUPPORTED_MEDIA_TYPE
+ default_detail = "Unsupported media type '%s' in request"
- def __init__(self, detail=None):
- self.detail = detail or self.default_detail
+ def __init__(self, media_type, detail=None):
+ self.detail = (detail or self.default_detail) % media_type
# class Throttled(Exception):
# def __init__(self, detail):