How to trigger a custom error from inside a Jinja template?
Answer from the comment:
There is no easy way to accomplish this – only via custom plugin. For details see: https://stackoverflow.com/questions/21778252/how-to-raise-an-exception-in-a-jinja2-macro