-# Copyright
-
-"""rss2email-specific errors
+# Copyright (C) 2012-2013 W. Trevor King <wking@tremily.us>
+#
+# This file is part of rss2email.
+#
+# rss2email is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 2 of the License, or (at your option) version 3 of
+# the License.
+#
+# rss2email is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# rss2email. If not, see <http://www.gnu.org/licenses/>.
+
+"""rss2email-specific errors
"""
from . import LOG as _LOG
+from . import __version__, __url__, __email__
import pprint as _pprint
message = (
'could not authenticate with mail server {} as user {}'.format(
server, username))
- super(SMTPConnectionError, self).__init__(
+ super(SMTPAuthenticationError, self).__init__(
server=server, message=message)
self.server = server
self.username = username
self.feed = feed
-class InvalidFeedName (FeedError):
+class InvalidFeedConfig (FeedError):
+ def __init__(self, setting, feed, message=None, **kwargs):
+ if not message:
+ message = "invalid feed configuration {}".format(
+ {setting: getattr(feed, setting)})
+ super(InvalidFeedConfig, self).__init__(
+ feed=feed, message=message, **kwargs)
+ self.setting = setting
+
+
+class InvalidFeedName (InvalidFeedConfig):
def __init__(self, name, **kwargs):
message = "invalid feed name '{}'".format(name)
- super(InvalidFeedName, self).__init__(message=message, **kwargs)
+ super(InvalidFeedName, self).__init__(
+ setting='name', message=message, **kwargs)
class ProcessingError (FeedError):
def __init__(self, parsed, feed, **kwargs):
if message is None:
message = 'error processing feed {}'.format(feed)
- super(FeedError, self).__init__(feed=feed, message=message)
+ super(ProcessingError, self).__init__(feed=feed, message=message)
self.parsed = parsed
def log(self):
_LOG.warning('=== END HERE ===')
-class HTTPError (ProcessingError):
+class HTTPError (FeedError):
def __init__(self, status, feed, **kwargs):
message = 'HTTP status {} fetching feed {}'.format(status, feed)
- super(FeedError, self).__init__(feed=feed, message=message)
+ super(HTTPError, self).__init__(feed=feed, message=message)
self.status = status
"'r2e new' first.")
-class NoToEmailAddress (FeedsError, FeedError):
- def __init__(self, **kwargs):
+class NoToEmailAddress (InvalidFeedConfig, FeedsError):
+ def __init__(self, feed, **kwargs):
message = 'no target email address has been defined'
- super(NoToEmailAddress, self).__init__(message=message, **kwargs)
+ super(NoToEmailAddress, self).__init__(
+ setting='to', feed=feed, message=message, **kwargs)
def log(self):
super(NoToEmailAddress, self).log()
"'r2e add name url emailaddress'.")
+class FeedIndexError (FeedsError, IndexError):
+ def __init__(self, index, message=None, **kwargs):
+ if message is None:
+ message = 'feed {!r} not found'.format(index)
+ super(FeedIndexError, self).__init__(
+ message=message, **kwargs)
+ self.index = index
+
+
class OPMLReadError (RSS2EmailError):
def __init__(self, **kwargs):
message = 'error reading OPML'
- super(RSS2EmailError, self).__init__(message=message, **kwargs)
+ super(OPMLReadError, self).__init__(message=message, **kwargs)