mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 18:08:38 -06:00
Added a custom 500 handler to include exception details
This commit is contained in:
parent
5def0e91d7
commit
23451fe974
@ -2,10 +2,12 @@ from django.conf.urls import include, url
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.views.defaults import page_not_found
|
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
|
from users.views import login, logout
|
||||||
|
|
||||||
|
|
||||||
|
handler500 = handle_500
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
|
||||||
# Default page
|
# Default page
|
||||||
|
@ -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.shortcuts import render
|
||||||
from django.utils.safestring import mark_safe
|
|
||||||
|
|
||||||
from circuits.models import Provider, Circuit
|
from circuits.models import Provider, Circuit
|
||||||
from dcim.models import Site, Rack, Device, ConsolePort, PowerPort, InterfaceConnection
|
from dcim.models import Site, Rack, Device, ConsolePort, PowerPort, InterfaceConnection
|
||||||
@ -47,6 +44,14 @@ def home(request):
|
|||||||
|
|
||||||
def trigger_500(request):
|
def trigger_500(request):
|
||||||
"""Hot-wired method of triggering a server error to test reporting."""
|
"""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 "
|
raise Exception("Congratulations, you've triggered an exception! Go tell all your friends what an exceptional "
|
||||||
"person you are.")
|
"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)
|
||||||
|
@ -12,13 +12,19 @@
|
|||||||
<div class="col-md-4 col-md-offset-4">
|
<div class="col-md-4 col-md-offset-4">
|
||||||
<div class="panel panel-danger" style="margin-top: 200px">
|
<div class="panel panel-danger" style="margin-top: 200px">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<strong>Server Error</strong>
|
<strong>
|
||||||
|
<i class="glyphicon glyphicon-warning-sign"></i>
|
||||||
|
Server Error
|
||||||
|
</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<p>There was a problem with your request. This error has been logged and administrative staff have
|
<p>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.</p>
|
been notified. Please return to the home page and try again.</p>
|
||||||
<p>If you are responsible for this installation, please consider
|
<p>If you are responsible for this installation, please consider
|
||||||
<a href="https://github.com/digitalocean/netbox/issues">filing a bug report</a>.</p>
|
<a href="https://github.com/digitalocean/netbox/issues">filing a bug report</a>. Additional
|
||||||
|
information is provided below:</p>
|
||||||
|
<pre><strong>{{ exception }}</strong><br />
|
||||||
|
{{ error }}</pre>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<a href="/" class="btn btn-primary">Home Page</a>
|
<a href="/" class="btn btn-primary">Home Page</a>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user