def server_error(request, template_name='500.html'):
if request.is_ajax() or request.META.get('HTTP_ACCEPT', 'text/plain') == 'application/json':
return JsonResponse({
'sentry': sentry_id_from_request(request),
'error': {
'title': _('Something went wrong'),
}
}, status=500)
try:
template = loader.get_template(template_name)
except TemplateDoesNotExist:
return HttpResponseServerError('<h1>Server Error (500)</h1>', content_type='text/html')
message = _('Something went wrong on our side... \n Please hold on while we fix it.').replace('\n', '<br>')
return HttpResponseServerError(template.render({
'sentry': sentry_id_from_request(request),
'error': {
'title': _('Something went wrong'),
'message': message,
'sentry': _('Fault code: #'),
}
}))
评论列表
文章目录