Improved config error reporting.
This commit is contained in:
@@ -14,6 +14,7 @@ from .oauth import OAuthHelper
|
||||
from .terminal import Terminal
|
||||
from .objects import curses_session
|
||||
from .subreddit import SubredditPage
|
||||
from .exceptions import ConfigError
|
||||
from .__version__ import __version__
|
||||
|
||||
|
||||
@@ -106,6 +107,9 @@ def main():
|
||||
# Launch the subreddit page
|
||||
page.loop()
|
||||
|
||||
except ConfigError as e:
|
||||
_logger.exception(e)
|
||||
print(e)
|
||||
except Exception as e:
|
||||
_logger.exception(e)
|
||||
raise
|
||||
|
||||
@@ -6,18 +6,14 @@ class EscapeInterrupt(Exception):
|
||||
"Signal that the ESC key has been pressed"
|
||||
|
||||
|
||||
class ConfigError(Exception):
|
||||
"There was a problem with the configuration"
|
||||
|
||||
|
||||
class RTVError(Exception):
|
||||
"Base RTV error class"
|
||||
|
||||
|
||||
class KeystringError(RTVError):
|
||||
"Unable to parse key string"
|
||||
|
||||
|
||||
class ConfigError(RTVError):
|
||||
"There was a problem with the configuration"
|
||||
|
||||
|
||||
class AccountError(RTVError):
|
||||
"Could not access user account"
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ class Page(object):
|
||||
self.oauth = oauth
|
||||
self.content = None
|
||||
self.nav = None
|
||||
self.controller = None
|
||||
|
||||
self.active = True
|
||||
self._row = 0
|
||||
|
||||
11
rtv/rtv.cfg
11
rtv/rtv.cfg
@@ -55,12 +55,12 @@ oauth_scope = edit,history,identity,mysubreddits,privatemessages,read,report,sav
|
||||
##############
|
||||
# Key Bindings
|
||||
##############
|
||||
; Multiple keys that represent the same command should be listed as a comma
|
||||
; seperated list. The a mixture of the following notations should be used to
|
||||
; describe keys.
|
||||
; If you would like to define custom bindings, copy this section into your
|
||||
; config file with the [bindings] heading. All commands must be bound to at
|
||||
; least one key for the config to be valid.
|
||||
;
|
||||
; 1.) Plain keys can be represented by either uppercase/lowercase characters
|
||||
; or the hexadecimal codes referring their ascii codes. For reference, see
|
||||
; or the hexadecimal numbers referring their ascii codes. For reference, see
|
||||
; https://en.wikipedia.org/wiki/ASCII#ASCII_printable_code_chart
|
||||
; e.g. Q, q, 1, ?
|
||||
; e.g. 0x20 (space), 0x3c (less-than sign)
|
||||
@@ -77,8 +77,9 @@ oauth_scope = edit,history,identity,mysubreddits,privatemessages,read,report,sav
|
||||
; Notes:
|
||||
; - Curses <KEY_ENTER> is unreliable and should always be used in conjunction
|
||||
; with <LF>.
|
||||
; - Use 0x20 for the space key
|
||||
|
||||
; General keys
|
||||
; Base page
|
||||
EXIT = q
|
||||
FORCE_EXIT = Q
|
||||
HELP = ?
|
||||
|
||||
@@ -17,14 +17,13 @@ class SubmissionController(PageController):
|
||||
class SubmissionPage(Page):
|
||||
|
||||
def __init__(self, reddit, term, config, oauth, url=None, submission=None):
|
||||
super(SubmissionPage, self).__init__(reddit, term, config, oauth)
|
||||
self.controller = SubmissionController(self, keymap=config.keymap)
|
||||
|
||||
super(SubmissionPage, self).__init__(reddit, term, config, oauth)
|
||||
if url:
|
||||
self.content = SubmissionContent.from_url(reddit, url, term.loader)
|
||||
else:
|
||||
self.content = SubmissionContent(submission, term.loader)
|
||||
|
||||
self.controller = SubmissionController(self, keymap=config.keymap)
|
||||
# Start at the submission post, which is indexed as -1
|
||||
self.nav = Navigator(self.content.get, page_index=-1)
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ from .page import Page, PageController, logged_in
|
||||
from .objects import Navigator, Color, Command
|
||||
from .submission import SubmissionPage
|
||||
from .subscription import SubscriptionPage
|
||||
from .terminal import Terminal
|
||||
|
||||
|
||||
class SubredditController(PageController):
|
||||
@@ -25,10 +24,10 @@ class SubredditPage(Page):
|
||||
name (string): Name of subreddit to open
|
||||
url (string): Optional submission to load upon start
|
||||
"""
|
||||
super(SubredditPage, self).__init__(reddit, term, config, oauth)
|
||||
|
||||
self.content = SubredditContent.from_name(reddit, name, term.loader)
|
||||
self.controller = SubredditController(self, keymap=config.keymap)
|
||||
|
||||
super(SubredditPage, self).__init__(reddit, term, config, oauth)
|
||||
self.content = SubredditContent.from_name(reddit, name, term.loader)
|
||||
self.nav = Navigator(self.content.get)
|
||||
|
||||
@SubredditController.register(Command('REFRESH'))
|
||||
|
||||
@@ -15,10 +15,10 @@ class SubscriptionController(PageController):
|
||||
class SubscriptionPage(Page):
|
||||
|
||||
def __init__(self, reddit, term, config, oauth):
|
||||
super(SubscriptionPage, self).__init__(reddit, term, config, oauth)
|
||||
|
||||
self.content = SubscriptionContent.from_user(reddit, term.loader)
|
||||
self.controller = SubscriptionController(self, keymap=config.keymap)
|
||||
|
||||
super(SubscriptionPage, self).__init__(reddit, term, config, oauth)
|
||||
self.content = SubscriptionContent.from_user(reddit, term.loader)
|
||||
self.nav = Navigator(self.content.get)
|
||||
self.subreddit_data = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user