Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a generic network exception to be raised #8133

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/5380.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Raise user friendly errors on network failures
6 changes: 6 additions & 0 deletions src/pip/_internal/network/utils.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to get address for host! seems weird for a ReadTimeoutError

It definitely makes sense for NewConnectionError in the context of #5380 (comment) but I don't think we should conflate the two exceptions types.

"and DNS settings.\nDetails: {}".format(exc)
)