mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
ExceptionHandlingMiddleware: Use server_error view for custom templates
This commit is contained in:
@ -4,10 +4,11 @@ import sys
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import ProgrammingError
|
||||
from django.http import Http404, HttpResponseRedirect, HttpResponseServerError
|
||||
from django.template import loader
|
||||
from django.http import Http404, HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
|
||||
from .views import server_error
|
||||
|
||||
BASE_PATH = getattr(settings, 'BASE_PATH', False)
|
||||
LOGIN_REQUIRED = getattr(settings, 'LOGIN_REQUIRED', False)
|
||||
|
||||
@ -78,11 +79,6 @@ class ExceptionHandlingMiddleware(object):
|
||||
):
|
||||
custom_template = 'exceptions/permission_error.html'
|
||||
|
||||
# Return a custom error message, or fall back to Django's default 500 error handling (500.html)
|
||||
# Return a custom error message, or fall back to Django's default 500 error handling
|
||||
if custom_template:
|
||||
type_, error, traceback = sys.exc_info()
|
||||
template = loader.get_template(custom_template)
|
||||
return HttpResponseServerError(template.render({
|
||||
'exception': str(type_),
|
||||
'error': error,
|
||||
}))
|
||||
return server_error(request, template_name=custom_template)
|
||||
|
Reference in New Issue
Block a user