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
This commit is contained in:
Sean Dague 2016-10-13 14:42:00 -04:00
parent bb8f9de455
commit 10ba290b00
1 changed files with 8 additions and 2 deletions

View File

@ -594,8 +594,14 @@ class Session(object):
except requests.exceptions.Timeout: except requests.exceptions.Timeout:
msg = 'Request to %s timed out' % url msg = 'Request to %s timed out' % url
raise exceptions.ConnectTimeout(msg) raise exceptions.ConnectTimeout(msg)
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError as e:
msg = 'Unable to establish connection to %s' % url # 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) raise exceptions.ConnectFailure(msg)
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
msg = 'Unexpected exception for %(url)s: %(error)s' % { msg = 'Unexpected exception for %(url)s: %(error)s' % {