Adding subreddit name to a few error messages.
This commit is contained in:
@@ -429,7 +429,10 @@ class SubredditContent(Content):
|
||||
try:
|
||||
self.get(0)
|
||||
except IndexError:
|
||||
raise exceptions.SubredditError('No submissions')
|
||||
full_name = self.name
|
||||
if self.order:
|
||||
full_name += '/' + self.order
|
||||
raise exceptions.NoSubmissionsError(full_name)
|
||||
|
||||
@classmethod
|
||||
def from_name(cls, reddit, name, loader, order=None, query=None):
|
||||
|
||||
@@ -22,8 +22,13 @@ class SubmissionError(RTVError):
|
||||
"Submission could not be loaded"
|
||||
|
||||
|
||||
class SubredditError(RTVError):
|
||||
"Subreddit could not be reached"
|
||||
class NoSubmissionsError(RTVError):
|
||||
"No submissions for the given page"
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
message = '`{0}` has no submissions'.format(name)
|
||||
super(NoSubmissionsError, self).__init__(message)
|
||||
|
||||
|
||||
class SubscriptionError(RTVError):
|
||||
|
||||
@@ -120,6 +120,7 @@ class LoadScreen(object):
|
||||
(praw.errors.OAuthScopeRequired, 'Not logged in'),
|
||||
(praw.errors.LoginRequired, 'Not logged in'),
|
||||
(praw.errors.InvalidCaptcha, 'Error, captcha required'),
|
||||
(praw.errors.InvalidSubreddit, '{0.args[0]}'),
|
||||
(praw.errors.PRAWException, '{0.__class__.__name__}'),
|
||||
(requests.exceptions.RequestException, '{0.__class__.__name__}'),
|
||||
]
|
||||
|
||||
@@ -399,8 +399,9 @@ def test_content_subreddit_me(reddit, oauth, refresh_token, terminal):
|
||||
|
||||
# If there is no submitted content, an error should be raised
|
||||
if terminal.loader.exception:
|
||||
assert isinstance(terminal.loader.exception, exceptions.SubredditError)
|
||||
|
||||
assert isinstance(terminal.loader.exception,
|
||||
exceptions.NoSubmissionsError)
|
||||
assert terminal.loader.exception.name == '/u/me'
|
||||
|
||||
def test_content_subscription(reddit, terminal):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user