aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'rest_framework/exceptions.py')
-rw-r--r--rest_framework/exceptions.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py
index ad52d172..852a08b1 100644
--- a/rest_framework/exceptions.py
+++ b/rest_framework/exceptions.py
@@ -15,7 +15,7 @@ class APIException(Exception):
Subclasses should provide `.status_code` and `.default_detail` properties.
"""
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
- default_detail = ''
+ default_detail = 'A server error occured'
def __init__(self, detail=None):
self.detail = detail or self.default_detail
@@ -29,6 +29,11 @@ class ParseError(APIException):
default_detail = 'Malformed request.'
+class ValidationError(APIException):
+ status_code = status.HTTP_400_BAD_REQUEST
+ default_detail = 'Invalid data in request.'
+
+
class AuthenticationFailed(APIException):
status_code = status.HTTP_401_UNAUTHORIZED
default_detail = 'Incorrect authentication credentials.'
@@ -54,7 +59,7 @@ class MethodNotAllowed(APIException):
class NotAcceptable(APIException):
status_code = status.HTTP_406_NOT_ACCEPTABLE
- default_detail = "Could not satisfy the request's Accept header"
+ default_detail = "Could not satisfy the request Accept header"
def __init__(self, detail=None, available_renderers=None):
self.detail = detail or self.default_detail