Improve network exception handling.

This commit is contained in:
Tomas Groth 2015-06-07 21:56:06 +01:00
parent 14031720be
commit 7eb506fae8
2 changed files with 9 additions and 1 deletions

View File

@ -414,6 +414,11 @@ def get_web_page(url, header=None, update_openlp=False):
page = None
if retries > CONNECTION_RETRIES:
raise
except socket.gaierror:
log.exception('Socket gaierror: {}'.format(url))
page = None
if retries > CONNECTION_RETRIES:
raise
except ConnectionRefusedError:
log.exception('ConnectionRefused: {}'.format(url))
page = None

View File

@ -748,7 +748,10 @@ def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, pre
"""
if not reference_url:
return None
page = get_web_page(reference_url, header, True)
try:
page = get_web_page(reference_url, header, True)
except:
page = None
if not page:
send_error_message('download')
return None