Skip to content

Commit

Permalink
CHANGED: map integrity error to 400
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Bredehöft committed Aug 3, 2015
1 parent d1720b0 commit ee55f43
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions drf_tools/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import logging

from django.core.exceptions import ValidationError, ObjectDoesNotExist, PermissionDenied
from django.db import IntegrityError
from django.http import Http404
from rest_framework.exceptions import APIException
from rest_framework import status
from rest_framework.response import Response


logger = logging.getLogger(__name__)


Expand All @@ -19,7 +19,7 @@ def exception_handler(exc):
headers['X-Throttle-Wait-Seconds'] = '%d' % exc.wait
headers['Retry-After'] = '%d' % exc.wait
status_code = exc.status_code
elif isinstance(exc, (ValueError, ValidationError)):
elif isinstance(exc, (ValueError, ValidationError, IntegrityError)):
status_code = status.HTTP_400_BAD_REQUEST
elif isinstance(exc, PermissionDenied):
status_code = status.HTTP_403_FORBIDDEN
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='drf-tools',
version="0.9.15",
version="0.9.16",
url='https://github.com/seebass/drf-tools',
license='MIT',
description='Multiple extensions and test utilities for Django REST Framework 3',
Expand Down

0 comments on commit ee55f43

Please sign in to comment.