this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Better error for non-existing user, closes #37

+9 -1
+9 -1
twitter_to_sqlite/utils.py
··· 34 34 source_re = re.compile('<a href="(?P<url>.*?)".*?>(?P<name>.*?)</a>') 35 35 36 36 37 + class UserDoesNotExist(click.ClickException): 38 + def __init__(self, identifier): 39 + super().__init__("User '{}' does not exist".format(identifier)) 40 + 41 + 37 42 def open_database(db_path): 38 43 db = sqlite_utils.Database(db_path) 39 44 # Only run migrations if this is an existing DB (has tables) ··· 120 125 url = "https://api.twitter.com/1.1/users/show.json" 121 126 if args: 122 127 url += "?" + urllib.parse.urlencode(args) 123 - profile = session.get(url).json() 128 + response = session.get(url) 129 + if response.status_code == 404: 130 + raise UserDoesNotExist(screen_name or user_id) 131 + profile = response.json() 124 132 save_users(db, [profile]) 125 133 return profile 126 134