Type of error tweepy / twitter api

I am using tweepy to create a twitter application. When users tweet / update profile etc. they will get some errors. I want to classify the error and provide the user with additional information.

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

The only way to classify an error is to compare ewith a string, for example Account update failed: Description is too long (maximum is 160 characters)?

+5
source share
1 answer

That's right, now this is the only way. Only one TweepError exception is thrown . It was created throughout the application with different text.

Here's the corresponding open issue on github. Thus, it is likely that in the future it will be improved.

+1
source

All Articles