Commit c966eb5d by Brian Coca

Merge pull request #10015 from bcoca/nicer_json_errors

handle json load errors as ansible error instead of ugly stacktrace
parents 4b0cc915 c09d27bc
......@@ -447,8 +447,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 '''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment