From 7d26de17f5698d9379cf53e1466b2691111b148b Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 13 Oct 2016 14:42:00 -0400 Subject: [PATCH] be more explicit about connection errors urllib/requests ConnectionError is a translation of SocketError. However, when we translate this *yet again* we drop the message from Requests. That message contains the actual SocketError details, which are often critical for debugging an issue. This keeps those details in the error message as we carry this up. Change-Id: I6b753fddaebdcbcfe62680585a5b6febf62647b3 --- keystoneauth1/session.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/keystoneauth1/session.py b/keystoneauth1/session.py index 54c0c65e..0039d609 100644 --- a/keystoneauth1/session.py +++ b/keystoneauth1/session.py @@ -631,8 +631,14 @@ class Session(object): except requests.exceptions.Timeout: msg = 'Request to %s timed out' % url raise exceptions.ConnectTimeout(msg) - except requests.exceptions.ConnectionError: - msg = 'Unable to establish connection to %s' % url + except requests.exceptions.ConnectionError as e: + # NOTE(sdague): urllib3/requests connection error is a + # translation of SocketError. However, SocketError + # happens for many different reasons, and that low + # level message is often really important in figuring + # out the difference between network misconfigurations + # and firewall blocking. + msg = 'Unable to establish connection to %s: %s' % (url, e) raise exceptions.ConnectFailure(msg) except requests.exceptions.RequestException as e: msg = 'Unexpected exception for %(url)s: %(error)s' % {