summaryrefslogtreecommitdiff
path: root/paramiko/ssh_exception.py
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2015-03-05 09:55:29 -0800
committerJeff Forcier <jeff@bitprophet.org>2015-03-05 10:10:39 -0800
commit136e0deef9c949a1b223244b696e6d870cc12e34 (patch)
treed01b2287914d3f903eecaec3ac8df628c2e12006 /paramiko/ssh_exception.py
parentb0a5ca8e3747a34082895bbd170a617f76ebe7e5 (diff)
downloadparamiko-136e0deef9c949a1b223244b696e6d870cc12e34.tar.gz
Add null errno to socket.error subclass.
Makes downstream code less likely to break when they expect errno+msg style socket error objects. Re #22
Diffstat (limited to 'paramiko/ssh_exception.py')
-rw-r--r--paramiko/ssh_exception.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/paramiko/ssh_exception.py b/paramiko/ssh_exception.py
index 169dad81..1fbebde8 100644
--- a/paramiko/ssh_exception.py
+++ b/paramiko/ssh_exception.py
@@ -135,7 +135,14 @@ class ProxyCommandFailure (SSHException):
class NoValidConnectionsError(socket.error):
"""
- High-level socket error wrapping 1+ actual socket.error objects.
+ Multiple connection attempts were made and no families succeeded.
+
+ This exception class wraps multiple "real" underlying connection errors,
+ all of which represent failed connection attempts. Because these errors are
+ not guaranteed to all be of the same error type (i.e. different errno,
+ class, message, etc) we expose a single unified error message and a
+ ``None`` errno so that instances of this class match most normal handling
+ of `socket.error` objects.
To see the wrapped exception objects, access the ``errors`` attribute.
``errors`` is a dict whose keys are address tuples (e.g. ``('127.0.0.1',
@@ -156,6 +163,7 @@ class NoValidConnectionsError(socket.error):
tail = addrs[-1][0]
msg = "Unable to connect to port {0} at {1} or {2}"
super(NoValidConnectionsError, self).__init__(
+ None, # stand-in for errno
msg.format(addrs[0][1], body, tail)
)
self.errors = errors