Better error messaging in utils

When a command responds with json that is unparseable, dump that unpareseable response instead of swallowing it.
This commit is contained in:
Nathan A. Feger 2012-06-14 13:17:38 -05:00
parent 1d553830f2
commit 9feb26ab28

View file

@ -182,7 +182,12 @@ def parse_json(data):
# not JSON, but try "Baby JSON" which allows many of our modules to not
# require JSON and makes writing modules in bash much simpler
results = {}
tokens = shlex.split(data)
try :
tokens = shlex.split(data)
except:
print "failed to parse json: "+ data
raise;
for t in tokens:
if t.find("=") == -1:
raise errors.AnsibleError("failed to parse: %s" % data)