mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user