Error reporting

Table of contents

  1. Common concepts
  2. Parse-time errors
  3. Runtime errors

Common concepts


Parse-time errors

It’s difficult to write complex template completely without errors. Missed braces, wrong characters, incorrect names… Everything is possible. So, it’s crucial to be able to get informative error report from the template engine. Jinja2Cpp provides such kind of report. Template::Load method (and TemplateEnv::LoadTemplate respectively) return instance of ErrorInfo class which contains details about the error. These details include:

  • Error code
  • Error description
  • File name and position (1-based line, col) of the error
  • Location description

For example, this template:

{{ {'key'=,} }}

produces the following error message:

noname.j2tpl:1:11: error: Expected expression, got: ','
{{ {'key'=,} }}

Runtime errors


< Prev | Up | Next >