Skip to content

Commit

Permalink
Merge pull request pypa#3274 from xavfernandez/index_exceptions
Browse files Browse the repository at this point in the history
Cleanup HTMLPage.get_page exception handling
  • Loading branch information
xavfernandez committed Nov 30, 2015
2 parents a178a5f + d48bc5c commit 1fd381e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pip/index.py
Expand Up @@ -794,21 +794,20 @@ def get_page(cls, link, skip_archives=True, session=None):

inst = cls(resp.content, resp.url, resp.headers)
except requests.HTTPError as exc:
level = 2 if exc.response.status_code == 404 else 1
cls._handle_fail(link, exc, url, level=level)
cls._handle_fail(link, exc, url)
except SSLError as exc:
reason = ("There was a problem confirming the ssl certificate: "
"%s" % exc)
cls._handle_fail(link, reason, url, meth=logger.info)
except requests.ConnectionError as exc:
cls._handle_fail(link, "connection error: %s" % exc, url)
except requests.Timeout:
cls._handle_fail(link, "timed out", url)
except SSLError as exc:
reason = ("There was a problem confirming the ssl certificate: "
"%s" % exc)
cls._handle_fail(link, reason, url, level=2, meth=logger.info)
else:
return inst

@staticmethod
def _handle_fail(link, reason, url, level=1, meth=None):
def _handle_fail(link, reason, url, meth=None):
if meth is None:
meth = logger.debug

Expand Down

0 comments on commit 1fd381e

Please sign in to comment.