twitter: wrap exceptions in str() before format()
this might also do something about #1, considering i'm also just doing blanket except Exception:s now. fingers crossed
This commit is contained in:
parent
124cf0bdb0
commit
b09c20e910
|
@ -95,8 +95,10 @@ class Twitter(Plugin):
|
||||||
try:
|
try:
|
||||||
tweet = self.twit.show_status(id=status)
|
tweet = self.twit.show_status(id=status)
|
||||||
return self._return_tweet_or_retweet_text(event, tweet=tweet, print_source=print_source, print_id=print_id)
|
return self._return_tweet_or_retweet_text(event, tweet=tweet, print_source=print_source, print_id=print_id)
|
||||||
except twython.exceptions.TwythonError as e:
|
except Exception as e:
|
||||||
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(e))
|
log.error("couldn't obtain status")
|
||||||
|
log.exception(e)
|
||||||
|
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(str(e)))
|
||||||
|
|
||||||
def handle_getuserstatus(self, connection, event, match):
|
def handle_getuserstatus(self, connection, event, match):
|
||||||
"""Get a status for a user. Allows for getting one other than the most recent."""
|
"""Get a status for a user. Allows for getting one other than the most recent."""
|
||||||
|
@ -130,12 +132,10 @@ class Twitter(Plugin):
|
||||||
tweet = tweets[-1*index]
|
tweet = tweets[-1*index]
|
||||||
return self._return_tweet_or_retweet_text(event, tweet=tweet, print_source=print_source,
|
return self._return_tweet_or_retweet_text(event, tweet=tweet, print_source=print_source,
|
||||||
print_id=print_id)
|
print_id=print_id)
|
||||||
except requests.exceptions.SSLError as ssle:
|
except Exception as e:
|
||||||
return self.bot.reply(event, "Couldn't obtain status: {0:s}, you can maybe try again".format(ssle))
|
log.error("couldn't obtain status")
|
||||||
except twython.exceptions.TwythonError as e:
|
log.exception(e)
|
||||||
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(e))
|
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(str(e)))
|
||||||
except ValueError as e:
|
|
||||||
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(e))
|
|
||||||
|
|
||||||
def handle_tweet(self, connection, event, match):
|
def handle_tweet(self, connection, event, match):
|
||||||
"""Tweet. Needs authentication."""
|
"""Tweet. Needs authentication."""
|
||||||
|
@ -151,8 +151,10 @@ class Twitter(Plugin):
|
||||||
return self.bot.reply(event, "'{0:s}' tweeted.".format(tweet))
|
return self.bot.reply(event, "'{0:s}' tweeted.".format(tweet))
|
||||||
else:
|
else:
|
||||||
return self.bot.reply(event, "Unknown error sending tweet(s).")
|
return self.bot.reply(event, "Unknown error sending tweet(s).")
|
||||||
except twython.exceptions.TwythonError as e:
|
except Exception as e:
|
||||||
return self.bot.reply(event, "Couldn't tweet: {0:s}".format(e))
|
log.error("couldn't tweet")
|
||||||
|
log.exception(e)
|
||||||
|
return self.bot.reply(event, "Couldn't tweet: {0:s}".format(str(e)))
|
||||||
|
|
||||||
def handle_replyto(self, connection, event, match):
|
def handle_replyto(self, connection, event, match):
|
||||||
"""Reply to a tweet, in the twitter in_reply_to_status_id sense. Needs authentication."""
|
"""Reply to a tweet, in the twitter in_reply_to_status_id sense. Needs authentication."""
|
||||||
|
@ -174,8 +176,10 @@ class Twitter(Plugin):
|
||||||
return self.bot.reply(event, "'{0:s}' tweeted.".format(tweet))
|
return self.bot.reply(event, "'{0:s}' tweeted.".format(tweet))
|
||||||
else:
|
else:
|
||||||
return self.bot.reply(event, "Unknown error sending tweet.")
|
return self.bot.reply(event, "Unknown error sending tweet.")
|
||||||
except twython.exceptions.TwythonError as e:
|
except Exception as e:
|
||||||
return self.bot.reply(event, "Couldn't tweet: {0:s}".format(e))
|
log.error("couldn't tweet")
|
||||||
|
log.exception(e)
|
||||||
|
return self.bot.reply(event, "Couldn't tweet: {0:s}".format(str(e)))
|
||||||
|
|
||||||
def handle_gettoken(self, connection, event, match):
|
def handle_gettoken(self, connection, event, match):
|
||||||
"""Get an oauth token, so that the user may authenticate the bot."""
|
"""Get an oauth token, so that the user may authenticate the bot."""
|
||||||
|
|
Loading…
Reference in New Issue