Python django.views.defaults.server_error() Examples

The following are 3 code examples of django.views.defaults.server_error(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.views.defaults , or try the search function .
Example #1
Source File: views.py    From mangaki with GNU Affero General Public License v3.0 7 votes vote down vote up
def generic_error_view(error, error_code):
    def error_view(request, exception=None):
        try:
            trope = Trope.objects.order_by('?').first()
        except DatabaseError:
            return server_error(request)

        parameters = {
            'error_code': error_code,
            'error': error,
        }
        if trope:
            parameters['trope'] = trope
            parameters['origin'] = trope.origin
        return render(request, 'error.html', parameters, status=error_code)

    return error_view 
Example #2
Source File: exceptions.py    From cmdb with GNU Lesser General Public License v3.0 5 votes vote down vote up
def interface_not_defined(request, exception, template_name=None):
    return HttpResponseNotFound('{"detail": "The interface not defined!"}')
#
# def server_error(request, template_name=None):
#     # data = {
#     #     "detail": "Server error: {}".format(str(exception))
#     # }
#     data = {
#         "detail": "Server error:"
#     }
#     return HttpResponseServerError(content=json.dumps(data)) 
Example #3
Source File: views.py    From esdc-ce with Apache License 2.0 5 votes vote down vote up
def server_error(request):
    """
    Custom 500 error handler.
    """
    if request.path.startswith('/api/'):
        return HttpResponseServerError('Server Error', content_type='application/json')
    return defaults.server_error(request)