Skip to content

Commit

Permalink
Returning proper 400 error on unreadable requests
Browse files Browse the repository at this point in the history
  • Loading branch information
audaciouscode committed May 23, 2017
1 parent 270646b commit 51bc87b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions views.py
Expand Up @@ -8,7 +8,7 @@
from django.conf import settings
from django.core.management import call_command
from django.http import HttpResponse, HttpResponseNotAllowed, JsonResponse, HttpResponseNotFound, \
FileResponse
FileResponse, UnreadablePostError
from django.shortcuts import render
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
Expand Down Expand Up @@ -135,7 +135,12 @@ def add_data_bundle(request):
response = {'message': 'Unable to parse data bundle.'}
response = HttpResponse(json.dumps(response, indent=2), \
content_type='application/json', \
status=201)
status=400)
except UnreadablePostError:
response = {'message': 'Unable to parse data bundle.'}
response = HttpResponse(json.dumps(response, indent=2), \
content_type='application/json', \
status=400)

for key, value in request.FILES.iteritems(): # pylint: disable=unused-variable
data_file = DataFile(data_bundle=bundle)
Expand Down

0 comments on commit 51bc87b

Please sign in to comment.