More helpful exception message when generating templates