mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 20:52:42 +01:00
Catch httplib.InvalidURL.
This commit is contained in:
parent
faa340913d
commit
7a3be8a8e5
@ -36,6 +36,7 @@ import supybot.fix as fix
|
|||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
import urllib2
|
import urllib2
|
||||||
|
import httplib
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
@ -44,6 +45,7 @@ Request = urllib2.Request
|
|||||||
class WebError(Exception):
|
class WebError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# XXX We should tighten this up a bit.
|
||||||
urlRe = re.compile(r"(\w+://[^\])>\s]+)", re.I)
|
urlRe = re.compile(r"(\w+://[^\])>\s]+)", re.I)
|
||||||
|
|
||||||
REFUSED = 'Connection refused.'
|
REFUSED = 'Connection refused.'
|
||||||
@ -94,6 +96,8 @@ def getUrlFd(url, headers=None):
|
|||||||
raise WebError, TIMED_OUT
|
raise WebError, TIMED_OUT
|
||||||
except (socket.error, socket.sslerror), e:
|
except (socket.error, socket.sslerror), e:
|
||||||
raise WebError, strError(e)
|
raise WebError, strError(e)
|
||||||
|
except httplib.InvalidURL, e:
|
||||||
|
raise WebError, 'Invalid URL: %s' % e
|
||||||
except urllib2.HTTPError, e:
|
except urllib2.HTTPError, e:
|
||||||
raise WebError, strError(e)
|
raise WebError, strError(e)
|
||||||
except urllib2.URLError, e:
|
except urllib2.URLError, e:
|
||||||
|
Loading…
Reference in New Issue
Block a user