Skip to content

Commit cf4a84a

Browse files
committed
fix(pip/_internal): Add a generic network exception to be raised
1 parent e8f5219 commit cf4a84a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

news/5380.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Raise user friendly errors on network failures

src/pip/_internal/network/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pip._vendor.requests.models import CONTENT_CHUNK_SIZE, Response
2+
from pip._vendor.urllib3.exceptions import NewConnectionError, ReadTimeoutError
23

34
from pip._internal.exceptions import NetworkConnectionError
45
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
@@ -95,3 +96,8 @@ def response_chunks(response, chunk_size=CONTENT_CHUNK_SIZE):
9596
if not chunk:
9697
break
9798
yield chunk
99+
except (NewConnectionError, ReadTimeoutError) as exc:
100+
raise NetworkConnectionError(
101+
"Failed to get address for host! Check your network connectivity "
102+
"and DNS settings.\nDetails: {}".format(exc)
103+
)

0 commit comments

Comments
 (0)