ansible/ansible — pull request #4541 by Kami (2013-10-16 14:53:54+00:00)
Title: Make errors which get thrown during template rendering more user-friendly

## Problem description

Currently, exceptions which get thrown when a template fails to render are very obnoxious which makes debugging those issues more painful than it should be.

## Proposed solution

I've included a very simple and naive solution in my pull request. Solution makes debugging slightly easier, but it's not perfect or ideal.

Current error message:

```bash
fatal: [127.0.0.1] => {'msg': "unexpected '}'", 'failed': True}
```

Error message after my change:

```bash
fatal: [127.0.0.1] => {'msg': "file: /ponies/nginx.conf.j2, line number: 37, error: unexpected '}'", 'failed': True}

```
Imo, a better solution would do something along those lines:

* Refactor the code and add utility function which takes "environment" and "data" argument and returns a rendered template. Basically it wraps environment.render call which currently happens in multiple places
* Centralize all the template error handling in this new function.

Comments? Feedback?