better error messages for template errors