From 9feb26ab2872cf7bae76467168d5d2181b3bb799 Mon Sep 17 00:00:00 2001 From: "Nathan A. Feger" Date: Thu, 14 Jun 2012 13:17:38 -0500 Subject: [PATCH] Better error messaging in utils When a command responds with json that is unparseable, dump that unpareseable response instead of swallowing it. --- lib/ansible/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ansible/utils.py b/lib/ansible/utils.py index d9805b13047..689829a3105 100644 --- a/lib/ansible/utils.py +++ b/lib/ansible/utils.py @@ -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)