AC-612 Return appropriate status code for server errors. Catch IntegrityError via the API and return a 400 response with error message instead of server error.

This commit is contained in:
Chris Church
2013-11-06 23:44:48 -05:00
parent 475c0d87c2
commit 2b01cc7059
4 changed files with 21 additions and 5 deletions

View File

@@ -2,18 +2,16 @@
# All Rights Reserved.
# Django
from django.shortcuts import render_to_response
from django.shortcuts import render
from django.template import RequestContext
def handle_error(request, status=404):
context = {}
#print request.path, status
if request.path.startswith('/admin/'):
template_name = 'admin/%d.html' % status
else:
template_name = '%d.html' % status
return render_to_response(template_name, context,
context_instance=RequestContext(request))
return render(request, template_name, context, status=status)
def handle_403(request):
return handle_error(request, 403)