title: How to get line number causing an exception (other than TemplateSyntaxError) in Jinja2 template?
body: <p>When a template contains a syntax error, Jinja throws a TemplateSyntaxError which has a <code>lineno</code> attribute containing the template line number where the error occurred.  </p>
  
  <p>How can I get the line number when an error occurs which is not a syntax error?  For example, the following tag:</p>
  
  <pre><code>{{ len(SettlementDate)+1 }}
  </code></pre>
  
  <p>causes Jinja to throw a TypeError if SettlementDate is not something list-like.  How can I then find out where this error occurred, for reporting to the user?  For my use case, sanitizing the context variables in advance is not an option.</p>