Skip to content

Commit

Permalink
Handle failure to connect to twitter more gracefully.
Browse files Browse the repository at this point in the history
  • Loading branch information
tibonihoo committed Jun 15, 2024
1 parent 134fe7f commit 5cc4fea
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions wom_tributary/utils/twitter_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
"""

import urllib.request, urllib.parse, urllib.error

import logging
logger = logging.getLogger(__name__)


import tweepy
from granary.twitter import Twitter
from oauth_dropins import twitter_auth
Expand Down Expand Up @@ -54,9 +59,8 @@ def try_get_authorized_client(
except urllib.error.HTTPError as e:
if e.code!=401: # HTTP Error 401: Authorization Required
raise
except urllib.error.HTTPError as e:
if e.code!=401: # HTTP Error 401: Authorization Required
raise
except Exception as e:
logging.error(f"Failed to set-up the Twitter client due to '{e}'")
return None


Expand Down

0 comments on commit 5cc4fea

Please sign in to comment.