Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get api_codes ? #1736

Closed
kornflex opened this issue Dec 20, 2021 · 1 comment
Closed

How to get api_codes ? #1736

kornflex opened this issue Dec 20, 2021 · 1 comment
Labels
Discussion This was converted/moved from/to a discussion Question This is a question

Comments

@kornflex
Copy link

Hello,

When I try to retweet already retweeted, I want to catch this error.

So :

try:
# retweet a tweet

except tweepy.TweepyException as e:
     if e.api_codes == 327:
     # something 

But I never enter in the conditionnal == 327 :/
It's an integer so I d'ont know how to catch it :/

Thank you for your help

@Harmon758
Copy link
Member

HTTPException.api_codes is a list of integers, so you can check for the specific error code within the list, e.g.:
if 327 in e.api_codes.

@Harmon758 Harmon758 added the Question This is a question label Dec 22, 2021
@tweepy tweepy locked and limited conversation to collaborators Dec 22, 2021
@Harmon758 Harmon758 converted this issue into discussion #1741 Dec 22, 2021
@Harmon758 Harmon758 added the Discussion This was converted/moved from/to a discussion label Dec 22, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Discussion This was converted/moved from/to a discussion Question This is a question
Projects
None yet
Development

No branches or pull requests

2 participants