From d83b0d1b81b65d95cd139d78ecf4a602d8d2218a Mon Sep 17 00:00:00 2001 From: nemunaire Date: Wed, 10 Sep 2014 21:33:28 +0200 Subject: [PATCH] Report HTTP error to users --- tools/web.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/web.py b/tools/web.py index a67091c..020a616 100644 --- a/tools/web.py +++ b/tools/web.py @@ -25,6 +25,7 @@ from urllib.parse import quote from urllib.parse import urlparse from urllib.request import urlopen +from exception import IRCException import xmlparser def isURL(url): @@ -108,7 +109,7 @@ def getURLContent(url, timeout=15): else: charset = cha[0] except http.client.BadStatusLine: - return None + raise IRCException("Invalid HTTP response") finally: conn.close() @@ -117,7 +118,7 @@ def getURLContent(url, timeout=15): elif (res.status == http.client.FOUND or res.status == http.client.MOVED_PERMANENTLY) and res.getheader("Location") != url: return getURLContent(res.getheader("Location"), timeout) else: - return None + raise IRCException("A HTTP error occurs: %d - %s" % (res.status, http.client.responses[res.status])) def getXML(url, timeout=15): """Get content page and return XML parsed content"""