From c99dab4df49fe117783b7ba095dc80db4d0d452a Mon Sep 17 00:00:00 2001 From: GLolol Date: Wed, 10 Dec 2014 16:32:10 -0800 Subject: [PATCH] Google: show the API's real error message instead of a generic error This makes it easier to debug issues like #955 in the future, whether it be session limit exceeded, an API change, etc. Also, remove duplicated checking clause for the HTTP error code. --- plugins/Google/plugin.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index 42dee4121..f331aa3e3 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -122,7 +122,8 @@ class Google(callbacks.PluginRegexp): headers=headers).decode('utf8') data = json.loads(text) if data['responseStatus'] != 200: - raise callbacks.Error(_('We broke The Google!')) + self.log.info("Google: unhandled error message: ", text) + raise callbacks.Error(data['responseDetails']) return data def formatData(self, data, bold=True, max=0, onetoone=False): @@ -187,9 +188,6 @@ class Google(callbacks.PluginRegexp): conf.supybot.plugins.Google.safesearch.validStrings: irc.errorInvalid('language') data = self.search(text, msg.args[0], dict(optlist)) - if data['responseStatus'] != 200: - irc.reply(_('We broke The Google!')) - return bold = self.registryValue('bold', msg.args[0]) max = self.registryValue('maximumResults', msg.args[0]) # We don't use supybot.reply.oneToOne here, because you generally