Adding subreddit name to a few error messages.

This commit is contained in:
Michael Lazar
2016-10-17 17:43:10 -07:00
parent de9edd1ce0
commit 9675fb4ba4
4 changed files with 15 additions and 5 deletions

View File

@@ -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):

View File

@@ -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):

View File

@@ -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__}'),
]