mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
better exception handling for unexpected exceptions
This commit is contained in:
parent
ae17b993d9
commit
e938f554b7
2 changed files with 6 additions and 3 deletions
|
@ -733,6 +733,10 @@ class Runner(object):
|
||||||
result = utils.jsonify(dict(changed=False, skipped=True))
|
result = utils.jsonify(dict(changed=False, skipped=True))
|
||||||
self.callbacks.on_skipped(host, None)
|
self.callbacks.on_skipped(host, None)
|
||||||
return ReturnData(host=host, result=result)
|
return ReturnData(host=host, result=result)
|
||||||
|
except errors.AnsibleError, e:
|
||||||
|
raise
|
||||||
|
except Exception, e:
|
||||||
|
raise errors.AnsibleError("Unexpected error while executing task: %s" % str(e))
|
||||||
|
|
||||||
# strip out any jinja2 template syntax within
|
# strip out any jinja2 template syntax within
|
||||||
# the data returned by the lookup plugin
|
# the data returned by the lookup plugin
|
||||||
|
|
|
@ -89,13 +89,12 @@ def lookup(name, *args, **kwargs):
|
||||||
tvars = kwargs.get('vars', None)
|
tvars = kwargs.get('vars', None)
|
||||||
|
|
||||||
if instance is not None:
|
if instance is not None:
|
||||||
# safely catch run failures per #5059
|
|
||||||
try:
|
try:
|
||||||
ran = instance.run(*args, inject=tvars, **kwargs)
|
ran = instance.run(*args, inject=tvars, **kwargs)
|
||||||
except errors.AnsibleUndefinedVariable:
|
except errors.AnsibleError:
|
||||||
raise
|
raise
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
ran = None
|
raise errors.AnsibleError('Unexpected error in during lookup: %s' % e)
|
||||||
if ran:
|
if ran:
|
||||||
ran = ",".join(ran)
|
ran = ",".join(ran)
|
||||||
return ran
|
return ran
|
||||||
|
|
Loading…
Reference in a new issue