5
我使用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)
?