Skip to content

Commit

Permalink
caputures the socket error if one is raised
Browse files Browse the repository at this point in the history
The exception handling would override the socket error on the connection if
a socket error was raised.  This patch will hold the socket error in the
connection object for evaluation.
  • Loading branch information
Peter Sprygada committed Jun 4, 2015
1 parent 388ef7d commit fa7bd63
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyeapi/eapilib.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class EapiConnection(object):
def __init__(self):
self.transport = None
self.error = None
self.socket_error = None
self._auth = None

def __str__(self):
Expand Down Expand Up @@ -350,7 +351,8 @@ def send(self, data):
return decoded

except (socket.error, ValueError) as exc:
self.error = exc
if isinstance(exc, socket.error):
self.socket_error = exc
raise ConnectionError(str(self), 'unable to connect to eAPI')

finally:
Expand Down

0 comments on commit fa7bd63

Please sign in to comment.