Opened 10 years ago

Closed 9 years ago

#24119 closed Bug (fixed)

Backend-agnostic tracebacks on template rendering errors

Reported by: Aymeric Augustin Owned by: nobody
Component: Template system Version: dev
Severity: Normal Keywords: multiple-template-engines
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently ExceptionReporter.get_traceback_data() contains a special case for exceptions raised during template rendering.

If the exception has a django_template_source attribute, which is set by the Debug variants of the Django template language's classes, information is gathered by ExceptionReporter.get_template_exception_info()

This logic should be embedded in the template engine. Third-part engines should have access to similar functionality through a public API.

Change History (4)

comment:1 by Aymeric Augustin, 10 years ago

Since this ticket describes a new feature and wasn't implemented before 1.8 alpha, it will make it into 1.9 at best. Jinja2 doesn't need it because it integrates with Python's native traceback system. Unfortunately, having only one use case makes it hard to validate a generic system.

comment:2 by Preston Timmons, 10 years ago

I've worked to address part of this issue in:

https://github.com/django/django/pull/4254

Instead of setting django_template_source on exceptions and then having the debug view call ExceptionReporter.get_template_exception_info(), all exception info is provided by the engine as Exception.template_debug.

Any other engine can now show the same type of rendering traceback by supplying a template_debug attribute. This is a generic dictionary with values like line, source_lines, start, end, etc.

This is a lot less obtrusive than the existing implementation. Django is able to provide this information by catching errors in only two spots--one for parsing and one for rendering.

Last edited 10 years ago by Preston Timmons (previous) (diff)

comment:3 by Tim Graham, 9 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:4 by Preston Timmons <prestontimmons@…>, 9 years ago

Resolution: fixed
Status: newclosed

In adff499:

Fixed #24119, #24120 -- Formalized debug integration for template backends.

Note: See TracTickets for help on using tickets.
Back to Top