mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
Merge pull request #10015 from bcoca/nicer_json_errors
handle json load errors as ansible error instead of ugly stacktrace
This commit is contained in:
commit
c966eb5d80
1 changed files with 5 additions and 1 deletions
|
@ -447,8 +447,12 @@ def role_yaml_parse(role):
|
||||||
|
|
||||||
def json_loads(data):
|
def json_loads(data):
|
||||||
''' parse a JSON string and return a data structure '''
|
''' 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):
|
def _clean_data(orig_data, from_remote=False, from_inventory=False):
|
||||||
''' remove jinja2 template tags from a string '''
|
''' remove jinja2 template tags from a string '''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue