Error handling

This commit is contained in:
Théo Piboubès
2015-08-20 13:34:37 +02:00
parent 9e27bee7e6
commit e7ad6067d2
2 changed files with 5 additions and 5 deletions

View File

@@ -160,10 +160,9 @@ def main():
subreddit = args.subreddit or 'front'
page = SubredditPage(stdscr, reddit, oauth, subreddit)
page.loop()
except praw.errors.OAuthAppRequired:
print('Invalid OAuth app config parameters')
except praw.errors.OAuthInvalidToken:
print('Invalid OAuth token')
except (praw.errors.OAuthAppRequired, praw.errors.OAuthInvalidToken,
praw.errors.HTTPException) as e:
print('Invalid OAuth data')
except requests.ConnectionError:
print('Connection timeout')
except requests.HTTPError:

View File

@@ -117,7 +117,8 @@ class OAuthTool(object):
access_token=self.access_info['access_token'],
refresh_token=self.access_info['refresh_token'])
self.set_token_expiration()
except (praw.errors.OAuthAppRequired, praw.errors.OAuthInvalidToken) as e:
except (praw.errors.OAuthAppRequired, praw.errors.OAuthInvalidToken,
praw.errors.HTTPException) as e:
show_notification(self.stdscr, ['Invalid OAuth data'])
else:
self.config['oauth']['access_token'] = self.access_info['access_token']