From d934824bff21e4a11226af61efba319be227f4f0 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 5 Sep 2014 16:29:46 +0100 Subject: Workin on --- rest_framework/exceptions.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'rest_framework/exceptions.py') 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 -- cgit v1.2.3