1
0
mirror of https://github.com/sjlongland/tornado-news.git synced 2025-09-13 10:03:14 +10:00

Improve error reporting on failed fetch.

This commit is contained in:
Stuart Longland 2017-10-15 08:00:07 +10:00
parent 0e0e566756
commit 9acacf2a96
Signed by: stuartl
GPG Key ID: F954BBBB7948D546

View File

@ -242,10 +242,14 @@ class FeedFetcher(object):
cached = False
self._log.debug('Body type: %s (http)', type(body))
except:
self._log.debug('Body of failed fetch: %s', response.body)
if cache_dir is not None:
cache_file = path.join(cache_dir, 'body')
if not path.isfile(cache_file):
raise
self._log.warning(
'Failed to retrieve %s (%s), trying cache', name, url)
body = open(path.join(cache_dir, 'body'),'rb').read()
'Failed to retrieve %s (%s), trying cache', name, url, exc_info=1)
body = open(cache_file,'rb').read()
cached = True
else:
raise