Opened 6 years ago
Closed 5 years ago
#30411 closed Cleanup/optimization (fixed)
Improve formatting of text tracebacks in technical 500 responses.
Reported by: | Daniel Hahler | Owned by: | Jerrod Martin |
---|---|---|---|
Component: | Error reporting | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
I think it would do better without extra newlines, and could just match the default output from Python itself.
Currently:
Traceback: File "…/Vcs/django/django/template/base.py" in __init__ 663. token.Meh During handling of the above exception ('str' object has no attribute 'Meh'), another exception occurred: File "…/Vcs/django/django/core/handlers/exception.py" in inner 34. response = get_response(request) File "…/Vcs/django/django/core/handlers/base.py" in _get_response 145. response = self.process_exception_by_middleware(e, request) File "…/Vcs/django/django/core/handlers/base.py" in _get_response 143. response = response.render() File "…/Vcs/django/django/template/response.py" in render 106. self.content = self.rendered_content File "…/Vcs/django/django/template/response.py" in rendered_content 83. content = template.render(context, self._request) File "…/Vcs/django/django/template/backends/django.py" in render 61. return self.template.render(context) File "…/Vcs/django/django/template/base.py" in render 171. return self._render(context) File "…/Vcs/django/django/test/utils.py" in instrumented_test_render 96. return self.nodelist.render(context) File "…/Vcs/django/django/template/base.py" in render 940. bit = node.render_annotated(context) File "…/Vcs/django/django/template/base.py" in render_annotated 907. return self.render(context) File "…/Vcs/django/django/template/loader_tags.py" in render 150. return compiled_parent._render(context) File "…/Vcs/django/django/test/utils.py" in instrumented_test_render 96. return self.nodelist.render(context) File "…/Vcs/django/django/template/base.py" in render 940. bit = node.render_annotated(context) File "…/Vcs/django/django/template/base.py" in render_annotated 907. return self.render(context) File "…/Vcs/django/django/template/loader_tags.py" in render 127. compiled_parent = self.get_parent(context) File "…/Vcs/django/django/template/loader_tags.py" in get_parent 124. return self.find_template(parent, context) File "…/Vcs/django/django/template/loader_tags.py" in find_template 104. template_name, skip=history, File "…/Vcs/django/django/template/engine.py" in find_template 125. template = loader.get_template(name, skip=skip) File "…/Vcs/django/django/template/loaders/base.py" in get_template 30. contents, origin, origin.template_name, self.engine, File "…/Vcs/django/django/template/base.py" in __init__ 156. self.nodelist = self.compile_nodelist() File "…/Vcs/django/django/template/base.py" in compile_nodelist 194. return parser.parse() File "…/Vcs/django/django/template/base.py" in parse 449. raise self.error(token, e) File "…/Vcs/django/django/template/base.py" in parse 447. filter_expression = self.compile_filter(token.contents) File "…/Vcs/django/django/template/base.py" in compile_filter 563. return FilterExpression(token, self) File "…/Vcs/django/django/template/base.py" in __init__ 666. "from '%s'" % (token[upto:], token)) Exception Type: TemplateSyntaxError at /a/login Exception Value: Could not parse the remainder: '("foo")' from 'myecho("foo")'
Better:
Traceback (most recent call last): File "…/Vcs/django/django/template/base.py", line 663, in __init__ token.Meh During handling of the above exception ('str' object has no attribute 'Meh'), another exception occurred: File "…/Vcs/django/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "…/Vcs/django/django/core/handlers/base.py", line 145, in _get_response response = self.process_exception_by_middleware(e, request) File "…/Vcs/django/django/core/handlers/base.py", line 143, in _get_response response = response.render() File "…/Vcs/django/django/template/response.py", line 106, in render self.content = self.rendered_content File "…/Vcs/django/django/template/response.py", line 83, in rendered_content content = template.render(context, self._request) File "…/Vcs/django/django/template/backends/django.py", line 61, in render return self.template.render(context) File "…/Vcs/django/django/template/base.py", line 171, in render return self._render(context) File "…/Vcs/django/django/test/utils.py", line 96, in instrumented_test_render return self.nodelist.render(context) File "…/Vcs/django/django/template/base.py", line 940, in render bit = node.render_annotated(context) File "…/Vcs/django/django/template/base.py", line 907, in render_annotated return self.render(context) File "…/Vcs/django/django/template/loader_tags.py", line 150, in render return compiled_parent._render(context) File "…/Vcs/django/django/test/utils.py", line 96, in instrumented_test_render return self.nodelist.render(context) File "…/Vcs/django/django/template/base.py", line 940, in render bit = node.render_annotated(context) File "…/Vcs/django/django/template/base.py", line 907, in render_annotated return self.render(context) File "…/Vcs/django/django/template/loader_tags.py", line 127, in render compiled_parent = self.get_parent(context) File "…/Vcs/django/django/template/loader_tags.py", line 124, in get_parent return self.find_template(parent, context) File "…/Vcs/django/django/template/loader_tags.py", line 104, in find_template template_name, skip=history, File "…/Vcs/django/django/template/engine.py", line 125, in find_template template = loader.get_template(name, skip=skip) File "…/Vcs/django/django/template/loaders/base.py", line 30, in get_template contents, origin, origin.template_name, self.engine, File "…/Vcs/django/django/template/base.py", line 156, in __init__ self.nodelist = self.compile_nodelist() File "…/Vcs/django/django/template/base.py", line 194, in compile_nodelist return parser.parse() File "…/Vcs/django/django/template/base.py", line 449, in parse raise self.error(token, e) File "…/Vcs/django/django/template/base.py", line 447, in parse filter_expression = self.compile_filter(token.contents) File "…/Vcs/django/django/template/base.py", line 563, in compile_filter return FilterExpression(token, self) File "…/Vcs/django/django/template/base.py", line 666, in __init__ "from '%s'" % (token[upto:], token)) Exception Type: TemplateSyntaxError at /a/login Exception Value: Could not parse the remainder: '("foo")' from 'myecho("foo")'
Change History (15)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
Component: | Core (Other) → Error reporting |
---|---|
Easy pickings: | set |
Triage Stage: | Unreviewed → Accepted |
OK, fine, improvements here welcome. Marking Easy Pickings... since it should just be formatting/template changes.
comment:3 by , 6 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 6 years ago
@Naved
Just to make sure it's not missed, there is an initial PR already at https://github.com/django/django/pull/11287.
comment:6 by , 5 years ago
Patch needs improvement: | set |
---|
comment:7 by , 5 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
Deassigning due to inactivity. (PR should be a good starting point.)
comment:8 by , 5 years ago
I'm new to Django and I am intending to accept this issue. However I have a few questions to ask.
Firstly, how to make Django use technical_500.txt as a template? When I raise exceptions in views Django use technical_500.html instead.
Secondly, why is the existing pull request not accepted, and how can I improve it?
comment:9 by , 5 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:10 by , 5 years ago
New pull request with tests. https://github.com/django/django/pull/11596
comment:11 by , 5 years ago
Patch needs improvement: | unset |
---|
comment:12 by , 5 years ago
Patch needs improvement: | set |
---|
comment:13 by , 5 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
comment:14 by , 5 years ago
Summary: | Improve traceback formatting in technical 500 text responses → Improve formatting of text tracebacks in technical 500 responses. |
---|
There are two other issues here: