aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/exceptions.py
diff options
context:
space:
mode:
authorTom Christie2012-10-17 14:59:37 +0100
committerTom Christie2012-10-17 14:59:37 +0100
commit4c17d1441f184eabea9000155f07445bcc2aa14c (patch)
tree4aa8219aefab33f02cd8e5dd97a0fbd6f8bfc76b /rest_framework/exceptions.py
parentbd8360c826b7a922eeb6226beb17853cfadb466c (diff)
downloaddjango-rest-framework-4c17d1441f184eabea9000155f07445bcc2aa14c.tar.bz2
Add `Unauthenticated` exception.
Diffstat (limited to 'rest_framework/exceptions.py')
-rw-r--r--rest_framework/exceptions.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py
index 572425b9..1597da61 100644
--- a/rest_framework/exceptions.py
+++ b/rest_framework/exceptions.py
@@ -23,6 +23,14 @@ class ParseError(APIException):
self.detail = detail or self.default_detail
+class Unauthenticated(APIException):
+ status_code = status.HTTP_401_UNAUTHENTICATED
+ default_detail = 'Incorrect or absent authentication credentials.'
+
+ def __init__(self, detail=None):
+ self.detail = detail or self.default_detail
+
+
class PermissionDenied(APIException):
status_code = status.HTTP_403_FORBIDDEN
default_detail = 'You do not have permission to perform this action.'