Handle errors in jmespath in json_query better (#22109)

* Handle errors in jmespath in json_query better

Catch any exceptions raised from jmespath and raise
an AnsibleFilterError instead.

Avoid a traceback.

Fixes #20379

* pep8
This commit is contained in:
Adrian Likins 2017-08-17 17:16:35 -04:00 committed by ansibot
parent d3ecf3efb7
commit 01c0b2f714
4 changed files with 122 additions and 5 deletions

View file

@ -440,7 +440,6 @@ class Base(with_metaclass(BaseMeta, object)):
# and assign the massaged value back to the attribute field
setattr(self, name, value)
except (TypeError, ValueError) as e:
raise AnsibleParserError("the field '%s' has an invalid value (%s), and could not be converted to an %s."
"The error was: %s" % (name, value, attribute.isa, e), obj=self.get_ds(), orig_exc=e)