diff options
Diffstat (limited to 'tagrss.py')
-rw-r--r-- | tagrss.py | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -33,18 +33,28 @@ class FeedTitleAlreadyInUseError(StorageError): class StorageConstraintViolationError(StorageError): pass + class SqliteMissingForeignKeySupportError(StorageError): pass class FeedFetchError(Exception): - def __init__(self, *, feed_source: str, status_code: typing.Optional[int] = None, underlying: typing.Optional[Exception] = None): + def __init__( + self, + *, + feed_source: str, + bad_source: bool = False, + status_code: typing.Optional[int] = None, + underlying: typing.Optional[Exception] = None, + ): + self.bad_source = bad_source if status_code: self.status_code = status_code super().__init__(f"Get {feed_source} returned HTTP {status_code}") else: super().__init__(f"Get {feed_source} failed: {underlying}") + FeedId = int Epoch = int ParsedFeed = feedparser.FeedParserDict @@ -398,9 +408,13 @@ class TagRss: response = requests.get(source) except requests.ConnectionError as e: raise FeedFetchError(feed_source=source, underlying=e) + except requests.exceptions.MissingSchema as e: + raise FeedFetchError(feed_source=source, bad_source=True, underlying=e) epoch_downloaded: int = int(time.time()) if response.status_code != requests.codes.ok: - raise FeedFetchError(feed_source=source, status_code=response.status_code) + raise FeedFetchError( + feed_source=source, bad_source=True, status_code=response.status_code + ) try: base: str = response.headers["Content-Location"] except KeyError: |