aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'djangorestframework/exceptions.py')
-rw-r--r--djangorestframework/exceptions.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/djangorestframework/exceptions.py b/djangorestframework/exceptions.py
index e70f55df..425b4b8f 100644
--- a/djangorestframework/exceptions.py
+++ b/djangorestframework/exceptions.py
@@ -1,3 +1,22 @@
+from djangorestframework import status
+
+
class ParseError(Exception):
- def __init__(self, detail):
- self.detail = detail
+ status_code = status.HTTP_400_BAD_REQUEST
+ default_detail = 'Malformed request'
+
+ def __init__(self, detail=None):
+ self.detail = detail or self.default_detail
+
+
+class PermissionDenied(Exception):
+ status_code = status.HTTP_403_FORBIDDEN
+ default_detail = 'You do not have permission to access this resource.'
+
+ def __init__(self, detail=None):
+ self.detail = detail or self.default_detail
+
+
+# class Throttled(Exception):
+# def __init__(self, detail):
+# self.detail = detail