12114 show filename and line number on 500 error page

This commit is contained in:
Arthur 2023-08-18 12:42:07 -07:00
parent 16e2283d19
commit 816f3e04d2
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,4 @@
import os
import platform
import sys
@ -49,10 +50,13 @@ def handler_500(request, template_name=ERROR_500_TEMPLATE_NAME):
except TemplateDoesNotExist:
return HttpResponseServerError('<h1>Server Error (500)</h1>', content_type='text/html')
type_, error, traceback = sys.exc_info()
fname = os.path.split(traceback.tb_frame.f_code.co_filename)[1]
lineno = traceback.tb_lineno
return HttpResponseServerError(template.render({
'error': error,
'exception': str(type_),
'fname': fname,
'lineno': lineno,
'netbox_version': settings.VERSION,
'python_version': platform.python_version(),
'plugins': get_installed_plugins(),

View File

@ -29,6 +29,8 @@
<pre class="block"><strong>{{ exception }}</strong><br />
{{ error }}
file: {{ fname }} line: {{ lineno }}
Python version: {{ python_version }}
NetBox version: {{ netbox_version }}
Plugins: {% for plugin, version in plugins.items %}