Exception.message gone in 3.x (#18221)

* Exception.message gone in 3.x
This commit is contained in:
Nathaniel Case 2016-10-28 13:48:16 -04:00 committed by GitHub
commit 4a067c3f50
3 changed files with 10 additions and 8 deletions

View file

@ -32,6 +32,7 @@ except ImportError:
from ansible.module_utils.basic import get_exception
from ansible.module_utils.network import NetworkError
from ansible.module_utils.six.moves import StringIO
from ansible.module_utils._text import to_native
ANSI_RE = [
re.compile(r'(\x1b\[\?1h\x1b=)'),
@ -51,7 +52,6 @@ class ShellError(Exception):
def __init__(self, msg, command=None):
super(ShellError, self).__init__(msg)
self.message = msg
self.command = command
@ -155,7 +155,7 @@ class Shell(object):
raise ShellError("timeout trying to send command: %s" % cmd)
except socket.error:
exc = get_exception()
raise ShellError("problem sending command to host: %s" % exc.message)
raise ShellError("problem sending command to host: %s" % to_native(exc))
return responses
def close(self):
@ -228,7 +228,7 @@ class CliBase(object):
except ShellError:
exc = get_exception()
raise NetworkError(
msg='failed to connect to %s:%s' % (host, port), exc=str(exc)
msg='failed to connect to %s:%s' % (host, port), exc=to_native(exc)
)
self._connected = True
@ -247,7 +247,7 @@ class CliBase(object):
return self.shell.send(commands)
except ShellError:
exc = get_exception()
raise NetworkError(exc.message, commands=commands)
raise NetworkError(to_native(exc), commands=commands)
def run_commands(self, commands):
return self.execute(to_list(commands))