django-rest-framework/djangorestframework/exceptions.py

30 lines
798 B
Python
Raw Normal View History

2012-08-25 16:43:28 +04:00
from djangorestframework import status
class ParseError(Exception):
2012-08-25 16:43:28 +04:00
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
2012-08-27 00:55:13 +04:00
default_detail = 'You do not have permission to access this resource'
2012-08-25 16:43:28 +04:00
def __init__(self, detail=None):
self.detail = detail or self.default_detail
2012-08-27 00:55:13 +04:00
class UnsupportedMediaType(Exception):
status_code = 415
default_detail = 'Unsupported media type in request'
def __init__(self, detail=None):
self.detail = detail or self.default_detail
2012-08-25 16:43:28 +04:00
# class Throttled(Exception):
# def __init__(self, detail):
# self.detail = detail