inja icon indicating copy to clipboard operation
inja copied to clipboard

Error message should state which template raised exception

Open davidchall opened this issue 1 year ago • 0 comments

Exceptions have a SourceLocation object, which stores the line and column numbers where the problem was encountered. This produces error messages like:

[inja.exception.render_error] (at 1:10) variable 'name' not found

https://github.com/pantor/inja/blob/17a59c0b78e620157c253b0c7643cfa987135f8d/include/inja/exceptions.hpp#L9-L12

When using the {% include %} and {% extends %} blocks, these numbers might correspond to a different source file. Therefore, this SourceLocation class should also store the name of the source file. Then the error message could look like:

[inja.exception.render_error] (at 1:10 in header.html) variable 'name' not found

I think this might be a significant quality-of-life improvement, but obviously is not a blocker or bug.

davidchall avatar Jul 08 '22 01:07 davidchall