[networking] Handle ConnectionError exceptions

This commit is contained in:
nemunaire 2015-07-03 02:31:27 +02:00
parent 3b8195b81b
commit 6415e4a697

View file

@ -31,6 +31,8 @@ def headers(url):
try:
conn.request("HEAD", o.path, None, {"User-agent":
"Nemubot v%s" % __version__})
except ConnectionError as e:
raise IRCException(e.strerror)
except socket.timeout:
raise IRCException("request timeout")
except socket.gaierror:
@ -68,6 +70,8 @@ def fetch(url, onNone=_onNoneDefault):
return onNone()
else:
return None
except ConnectionError as e:
raise IRCException(e.strerror)
except socket.timeout:
raise IRCException("The request timeout when trying to access the page")
except socket.error as e: