Give a nice message when trying to use undefined variable within jinja2 template

Instead of write:
{'msg': "TypeError: argument of type 'StrictUndefined' is not iterable", 'failed': True}
Give a nice message similar to the one defined in:
template_from_string function.