Fixing error handling for the inbox command
This commit is contained in:
@@ -192,6 +192,7 @@ def main():
|
||||
reddit = praw.Reddit(user_agent=user_agent,
|
||||
decode_html_entities=False,
|
||||
disable_update_check=True,
|
||||
timeout=10, # 10 second request timeout
|
||||
handler=RequestHeaderRateLimiter())
|
||||
|
||||
# Dial the request cache up from 30 seconds to 5 minutes
|
||||
@@ -247,4 +248,5 @@ def main():
|
||||
if 'reddit' in locals():
|
||||
reddit.handler.http.close()
|
||||
|
||||
|
||||
sys.exit(main())
|
||||
|
||||
@@ -159,6 +159,7 @@ class LoadScreen(object):
|
||||
(praw.errors.InvalidCaptcha, 'Error, captcha required'),
|
||||
(praw.errors.InvalidSubreddit, '{0.args[0]}'),
|
||||
(praw.errors.PRAWException, '{0.__class__.__name__}'),
|
||||
(requests.exceptions.Timeout, 'HTTP request timed out'),
|
||||
(requests.exceptions.RequestException, '{0.__class__.__name__}'),
|
||||
]
|
||||
|
||||
|
||||
10
rtv/page.py
10
rtv/page.py
@@ -290,9 +290,13 @@ class Page(object):
|
||||
Checks the inbox for unread messages and displays a notification.
|
||||
"""
|
||||
|
||||
inbox = len(list(self.reddit.get_unread(limit=1)))
|
||||
message = 'New Messages' if inbox > 0 else 'No New Messages'
|
||||
self.term.show_notification(message)
|
||||
with self.term.loader('Loading'):
|
||||
messages = self.reddit.get_unread(limit=1)
|
||||
inbox = len(list(messages))
|
||||
|
||||
if self.term.loader.exception is None:
|
||||
message = 'New Messages' if inbox > 0 else 'No New Messages'
|
||||
self.term.show_notification(message)
|
||||
|
||||
@PageController.register(Command('COPY_PERMALINK'))
|
||||
def copy_permalink(self):
|
||||
|
||||
Reference in New Issue
Block a user