mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
remove usless tb initiator
always pass proper tb
This commit is contained in:
parent
f018b9d07d
commit
8fd0fbe431
2 changed files with 7 additions and 12 deletions
|
@ -20,8 +20,6 @@ from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
import traceback
|
|
||||||
|
|
||||||
from ansible.errors.yaml_strings import (
|
from ansible.errors.yaml_strings import (
|
||||||
YAML_COMMON_DICT_ERROR,
|
YAML_COMMON_DICT_ERROR,
|
||||||
|
@ -72,8 +70,6 @@ class AnsibleError(Exception):
|
||||||
if orig_exc:
|
if orig_exc:
|
||||||
self.orig_exc = orig_exc
|
self.orig_exc = orig_exc
|
||||||
|
|
||||||
self.tb = ''.join(traceback.format_tb(sys.exc_info()[2]))
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.message
|
return self.message
|
||||||
|
|
||||||
|
|
|
@ -275,13 +275,12 @@ class InventoryManager(object):
|
||||||
break
|
break
|
||||||
except AnsibleParserError as e:
|
except AnsibleParserError as e:
|
||||||
display.debug('%s was not parsable by %s' % (source, plugin_name))
|
display.debug('%s was not parsable by %s' % (source, plugin_name))
|
||||||
# Ansible error was created before the exception has been processed,
|
tb = ''.join(traceback.format_tb(sys.exc_info()[2]))
|
||||||
# so traceback can only be obtained within this context
|
failures.append({'src': source, 'plugin': plugin_name, 'exc': e, 'tb': tb})
|
||||||
e.tb = ''.join(traceback.format_tb(sys.exc_info()[2]))
|
|
||||||
failures.append({'src': source, 'plugin': plugin_name, 'exc': e})
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
display.debug('%s failed to parse %s' % (plugin_name, source))
|
display.debug('%s failed while attempting to parse %s' % (plugin_name, source))
|
||||||
failures.append({'src': source, 'plugin': plugin_name, 'exc': AnsibleError(e)})
|
tb = ''.join(traceback.format_tb(sys.exc_info()[2]))
|
||||||
|
failures.append({'src': source, 'plugin': plugin_name, 'exc': AnsibleError(e), 'tb': tb})
|
||||||
else:
|
else:
|
||||||
display.vvv("%s declined parsing %s as it did not pass it's verify_file() method" % (plugin_name, source))
|
display.vvv("%s declined parsing %s as it did not pass it's verify_file() method" % (plugin_name, source))
|
||||||
else:
|
else:
|
||||||
|
@ -289,8 +288,8 @@ class InventoryManager(object):
|
||||||
# only if no plugin processed files should we show errors.
|
# only if no plugin processed files should we show errors.
|
||||||
for fail in failures:
|
for fail in failures:
|
||||||
display.warning(u'\n* Failed to parse %s with %s plugin: %s' % (to_text(fail['src']), fail['plugin'], to_text(fail['exc'])))
|
display.warning(u'\n* Failed to parse %s with %s plugin: %s' % (to_text(fail['src']), fail['plugin'], to_text(fail['exc'])))
|
||||||
if hasattr(fail['exc'], 'tb'):
|
if 'tb' in fail:
|
||||||
display.vvv(to_text(fail['exc'].tb))
|
display.vvv(to_text(fail['tb']))
|
||||||
if C.INVENTORY_ANY_UNPARSED_IS_FAILED:
|
if C.INVENTORY_ANY_UNPARSED_IS_FAILED:
|
||||||
raise AnsibleError(u'Completely failed to parse inventory source %s' % (source))
|
raise AnsibleError(u'Completely failed to parse inventory source %s' % (source))
|
||||||
if not parsed:
|
if not parsed:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue