1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

auto tb on vvv+ or debug (#26106)

* auto tb on vvv+ or debug

* updated as per feedback
This commit is contained in:
Brian Coca 2017-06-28 10:08:38 -04:00 committed by GitHub
parent 11836a0296
commit d5f4c2a54b

View file

@ -2134,6 +2134,11 @@ class AnsibleModule(object):
if 'changed' not in kwargs:
kwargs['changed'] = False
# add traceback if debug or high verbosity and it is missing
# Note: badly named as exception, it is really always been 'traceback'
if 'exception' not in kwargs and sys.exc_info()[2] and (self._debug or self._verbosity >= 3):
kwargs['exception'] = ''.join(traceback.format_tb(sys.exc_info()[2]))
self.do_cleanup_files()
self._return_formatted(kwargs)
sys.exit(1)