Add IfMatchMissing exception

Needed to make testing easier.
This commit is contained in:
George Hickman 2013-03-20 23:55:13 -07:00
parent cfd083d759
commit a337dc3b5f
2 changed files with 9 additions and 1 deletions

View File

@ -96,6 +96,14 @@ class PreconditionFailed(APIException):
self.detail = detail or self.default_detail
class IfMatchMissing(APIException):
default_detail = 'IF_MATCH header is required'
status_code = 400
def __init__(self, detail=None):
self.detail = detail or self.default_detail
class ConfigurationError(Exception):
"""
Indicates an internal server error.

View File

@ -401,7 +401,7 @@ class APIView(View):
if getattr(self, 'use_etags', False) and request.method.lower() in ('put', 'delete'):
self.etag_header = request.META.get('HTTP_IF_MATCH')
if self.etag_header is None:
return Response({'detail': 'IF_MATCH header is required'}, status=400, exception=True)
raise exceptions.IfMatchMissing
response = handler(request, *args, **kwargs)