异常
- exception _jinja2.UndefinedError(_message=None)
- Raised if a template tries to operate on Undefined.
- exception _jinja2.TemplatesNotFound(_names=(), message=None)
- Like TemplateNotFound but raised if multiple templatesare selected. This is a subclass of TemplateNotFoundexception, so just catching the base exception will catch both.
New in version 2.2.
- exception _jinja2.TemplateSyntaxError(_message, lineno, name=None, filename=None)
Raised to tell the user that there is a problem with the template.
文件名和错误消息是字节串而不是 unicode 字符串的原因是,在 Python 2.x中,不对异常和回溯使用 unicode ,编译器同样。这会在 Python 3 改变。
- exception _jinja2.TemplateAssertionError(_message, lineno, name=None, filename=None)
- Like a template syntax error, but covers cases where something in thetemplate caused an error at compile time that wasn’t necessarily causedby a syntax error. However it’s a direct subclass ofTemplateSyntaxError and has the same attributes.