diff --git a/netbox/netbox/urls.py b/netbox/netbox/urls.py index a7f908544..3a9d6b00a 100644 --- a/netbox/netbox/urls.py +++ b/netbox/netbox/urls.py @@ -2,10 +2,12 @@ from django.conf.urls import include, url from django.contrib import admin from django.views.defaults import page_not_found -from views import home, trigger_500 +from views import home, trigger_500, handle_500 from users.views import login, logout +handler500 = handle_500 + urlpatterns = [ # Default page diff --git a/netbox/netbox/views.py b/netbox/netbox/views.py index 38988f6c7..9fda7f92c 100644 --- a/netbox/netbox/views.py +++ b/netbox/netbox/views.py @@ -1,9 +1,6 @@ -from markdown import markdown +import sys -from django.conf import settings -from django.http import Http404 from django.shortcuts import render -from django.utils.safestring import mark_safe from circuits.models import Provider, Circuit from dcim.models import Site, Rack, Device, ConsolePort, PowerPort, InterfaceConnection @@ -47,6 +44,14 @@ def home(request): def trigger_500(request): """Hot-wired method of triggering a server error to test reporting.""" - raise Exception("Congratulations, you've triggered an exception! Go tell all your friends what an exceptional " "person you are.") + + +def handle_500(request): + """Custom server error handler""" + type_, error, traceback = sys.exc_info() + return render(request, '500.html', { + 'exception': str(type_), + 'error': error, + }, status=500) diff --git a/netbox/templates/500.html b/netbox/templates/500.html index 4f65eae90..33fee68db 100644 --- a/netbox/templates/500.html +++ b/netbox/templates/500.html @@ -12,13 +12,19 @@
- Server Error + + + Server Error +

There was a problem with your request. This error has been logged and administrative staff have been notified. Please return to the home page and try again.

If you are responsible for this installation, please consider - filing a bug report.

+ filing a bug report. Additional + information is provided below:

+
{{ exception }}
+{{ error }}