From 693cdc302f420f98deb98958e4f04b351b014f7c Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sat, 6 Sep 2014 19:44:18 -0500 Subject: [PATCH] Catch errors while searching. --- earwigbot/wiki/copyvios/search.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/earwigbot/wiki/copyvios/search.py b/earwigbot/wiki/copyvios/search.py index 9126b93..8d89960 100644 --- a/earwigbot/wiki/copyvios/search.py +++ b/earwigbot/wiki/copyvios/search.py @@ -22,8 +22,10 @@ from gzip import GzipFile from json import loads +from socket import error from StringIO import StringIO from urllib import quote +from urllib2 import URLError from earwigbot import importer from earwigbot.exceptions import SearchQueryError @@ -90,8 +92,11 @@ class YahooBOSSSearchEngine(BaseSearchEngine): req = oauth.Request(method="GET", url=url, parameters=params) req.sign_request(oauth.SignatureMethod_HMAC_SHA1(), consumer, None) - response = self.opener.open(self._build_url(url, req)) - result = response.read() + try: + response = self.opener.open(self._build_url(url, req)) + result = response.read() + except (URLError, error) as exc: + raise SearchQueryError("Yahoo! BOSS Error: " + str(exc)) if response.headers.get("Content-Encoding") == "gzip": stream = StringIO(result)