mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
handle json load errors as ansible error instead of ugly stacktrace
This commit is contained in:
@@ -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 '''
|
||||
|
||||
Reference in New Issue
Block a user