Do not use str() on exceptions (#46950)

This commit is contained in:
Martin Krizek
2018-11-09 07:59:30 +01:00
committed by GitHub
parent 2436aa1a4e
commit a80c25cbd9
30 changed files with 76 additions and 66 deletions

View File

@@ -274,7 +274,7 @@ class DocCLI(CLI):
except Exception as e:
display.vvv(traceback.format_exc())
raise AnsibleError(
"%s %s missing documentation (or could not parse documentation): %s\n" % (plugin_type, plugin, str(e)))
"%s %s missing documentation (or could not parse documentation): %s\n" % (plugin_type, plugin, to_native(e)))
def find_plugins(self, path, ptype):

View File

@@ -39,7 +39,7 @@ from ansible.galaxy.api import GalaxyAPI
from ansible.galaxy.login import GalaxyLogin
from ansible.galaxy.role import GalaxyRole
from ansible.galaxy.token import GalaxyToken
from ansible.module_utils._text import to_text
from ansible.module_utils._text import to_native, to_text
from ansible.playbook.role.requirement import RoleRequirement
try:
@@ -361,7 +361,7 @@ class GalaxyCLI(CLI):
raise AnsibleError("Invalid role requirements file")
f.close()
except (IOError, OSError) as e:
raise AnsibleError('Unable to open %s: %s' % (role_file, str(e)))
raise AnsibleError('Unable to open %s: %s' % (role_file, to_native(e)))
else:
# roles were specified directly, so we'll just go out grab them
# (and their dependencies, unless the user doesn't want us to).
@@ -397,7 +397,7 @@ class GalaxyCLI(CLI):
try:
installed = role.install()
except AnsibleError as e:
display.warning("- %s was NOT installed successfully: %s " % (role.name, str(e)))
display.warning(u"- %s was NOT installed successfully: %s " % (role.name, to_text(e)))
self.exit_without_ignore()
continue
@@ -451,7 +451,7 @@ class GalaxyCLI(CLI):
else:
display.display('- %s is not installed, skipping.' % role_name)
except Exception as e:
raise AnsibleError("Failed to remove role %s: %s" % (role_name, str(e)))
raise AnsibleError("Failed to remove role %s: %s" % (role_name, to_native(e)))
return 0