fix(pip/_internal): Add a generic network exception to be raised

This commit is contained in:
gutsytechster 2020-04-25 13:51:25 +05:30 committed by Prashant Sharma
parent e8f52198a9
commit cf4a84a8da
No known key found for this signature in database
GPG Key ID: 2590C52D85511782
2 changed files with 7 additions and 0 deletions

1
news/5380.bugfix Normal file
View File

@ -0,0 +1 @@
Raise user friendly errors on network failures

View File

@ -1,4 +1,5 @@
from pip._vendor.requests.models import CONTENT_CHUNK_SIZE, Response
from pip._vendor.urllib3.exceptions import NewConnectionError, ReadTimeoutError
from pip._internal.exceptions import NetworkConnectionError
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
@ -95,3 +96,8 @@ def response_chunks(response, chunk_size=CONTENT_CHUNK_SIZE):
if not chunk:
break
yield chunk
except (NewConnectionError, ReadTimeoutError) as exc:
raise NetworkConnectionError(
"Failed to get address for host! Check your network connectivity "
"and DNS settings.\nDetails: {}".format(exc)
)