mirror of https://github.com/pypa/pip
fix(pip/_internal): Add a generic network exception to be raised
This commit is contained in:
parent
e8f52198a9
commit
cf4a84a8da
|
@ -0,0 +1 @@
|
||||||
|
Raise user friendly errors on network failures
|
|
@ -1,4 +1,5 @@
|
||||||
from pip._vendor.requests.models import CONTENT_CHUNK_SIZE, Response
|
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.exceptions import NetworkConnectionError
|
||||||
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
|
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:
|
if not chunk:
|
||||||
break
|
break
|
||||||
yield chunk
|
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)
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue