use global GrumbleError for web exceptions
This commit is contained in:
@@ -6,6 +6,7 @@ author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
|
||||
from urllib.parse import quote as urlquote
|
||||
from urllib.error import HTTPError
|
||||
from tools import GrumbleError
|
||||
import web
|
||||
import lxml.html
|
||||
|
||||
@@ -20,8 +21,7 @@ def rule34(phenny, input):
|
||||
try:
|
||||
req = web.get("http://rule34.xxx/index.php?page=post&s=list&tags={0}".format(urlquote(q)))
|
||||
except (HTTPError, IOError):
|
||||
phenny.say("THE INTERNET IS FUCKING BROKEN. Please try again later.")
|
||||
return
|
||||
raise GrumbleError("THE INTERNET IS FUCKING BROKEN. Please try again later.")
|
||||
|
||||
doc = lxml.html.fromstring(req)
|
||||
doc.make_links_absolute('http://rule34.xxx/')
|
||||
@@ -33,8 +33,7 @@ def rule34(phenny, input):
|
||||
try:
|
||||
link = thumbs[0].find('a').attrib['href']
|
||||
except AttributeError:
|
||||
phenny.say("THE INTERNET IS FUCKING BROKEN. Please try again later.")
|
||||
return
|
||||
raise GrumbleError("THE INTERNET IS FUCKING BROKEN. Please try again later.")
|
||||
|
||||
response = '!!NSFW!! -> {0} <- !!NSFW!!'.format(link)
|
||||
phenny.reply(response)
|
||||
|
||||
Reference in New Issue
Block a user