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)?
source
share