From e7ad6067d2ca68a5fb2c2a64145e7b2a29de7886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Piboub=C3=A8s?= Date: Thu, 20 Aug 2015 13:34:37 +0200 Subject: [PATCH] Error handling --- rtv/__main__.py | 7 +++---- rtv/oauth.py | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rtv/__main__.py b/rtv/__main__.py index bb9337d..27c0387 100644 --- a/rtv/__main__.py +++ b/rtv/__main__.py @@ -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: diff --git a/rtv/oauth.py b/rtv/oauth.py index 3cf245d..81399de 100644 --- a/rtv/oauth.py +++ b/rtv/oauth.py @@ -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']