Skip to content

Commit

Permalink
Exception Handling
Browse files Browse the repository at this point in the history
Handle HTTP exceptions when fetching entries so that a failure won't
cause diffengine to exit abruptly.
  • Loading branch information
edsu committed Jan 16, 2017
1 parent c602b6b commit b9ce3ae
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion diffengine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ def get_latest(self):

# fetch the current readability-ized content for the page
logging.info("checking %s", self.url)
resp = requests.get(self.url, headers={"User-Agent": UA})
try:
resp = requests.get(self.url, headers={"User-Agent": UA})
except Exception as e:
logging.error("unable to fetch %s: %s", self.url, e)
return None

if resp.status_code != 200:
logging.warn("Got %s when fetching %s", resp.status_code, self.url)
return None
Expand Down

0 comments on commit b9ce3ae

Please sign in to comment.