tweepy/twitter api错误类型

问题描述:

我使用tweepy来制作twitter应用程序。 当用户推特/更新配置文件等,他们会得到一些错误。我想分类错误并为用户提供更多信息。tweepy/twitter api错误类型

try: 
    tweet/update profile/ follow.... 

except tweepy.TweepError, e: 

    if tweepy.TweepError is "Account update failed: Description is too long (maximum is 160 characters)" 
     Do something 
    if tweepy.TweepError is "Failed to send request: Invalid request URL: http://api.twitter.com/1/account/update_profile.json?location=%E5%85%B5%E5%BA%A" 
     Do something 
    if tweepy.TweepError is "[{u'message': u'Over capacity', u'code': 130}]" 
     Do something 

是分类错误的唯一方法是比较e与字符串,例如,Account update failed: Description is too long (maximum is 160 characters)

对,现在是唯一的方法。定义的异常只有一个TweepError。它在整个应用程序中以不同的文字提出。

这是github上的相关开放issue。所以有可能在未来有所改善。