handle json load errors as ansible error instead of ugly stacktrace

This commit is contained in:
Brian Coca 2015-01-15 12:03:13 -05:00
parent 02bc014bcd
commit c09d27bca1

View file

@ -462,8 +462,12 @@ def role_yaml_parse(role):
def json_loads(data):
''' parse a JSON string and return a data structure '''
try:
loaded = json.loads(data)
except ValueError,e:
raise errors.AnsibleError("Unable to read provided data as JSON: %s" % str(e))
return json.loads(data)
return loaded
def _clean_data(orig_data, from_remote=False, from_inventory=False):
''' remove jinja2 template tags from a string '''