Added error handling for feed processing errors

This commit adds error handling for feed processing errors in the RSS
bot's feed polling logic. The previous version was failing to handle
exceptions that were thrown during the feed parsing process, which could
lead to unpredictable behavior and potential data corruption. This new
version catches any exceptions that occur during the feed parsing step
and logs them, preventing the bot from becoming stuck in an infinite
loop due to these errors.

The changes include a try/except block around the feed parsing code,
where any exceptions are caught and logged using Python's logging
module. The bot's state is not modified when there is an error during
feed processing, which ensures that the bot does not become stuck in an
infinite loop due to errors. Additionally, the commit includes a new
logger method for logging exceptions, which helps identify any issues
with the feed parsing process and prevents them from affecting the bot's
overall performance.

This commit has several benefits:

* It improves the reliability of the RSS bot by handling errors that
could occur during feed processing and preventing the bot from becoming
stuck in an infinite loop due to these errors.
* It makes it easier for users to troubleshoot issues with the RSS bot,
since error messages are now being logged and can be easily identified.
* It helps to prevent data corruption by ensuring that the bot's state
is not modified when there is an error during feed processing.
This commit is contained in:
Kumi 2024-03-02 17:51:15 +01:00
parent ec815b1487
commit db37f31b93
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -563,7 +563,8 @@ class RSSBot:
await self.send_state_event(
room, "rssbot.feed_state", {"timestamp": new_timestamp}, feed
)
except:
except Exception as e:
self.logger.log(f"Error processing feed at {feed}: {e}")
await self.send_message(
room,
f"Could not access or parse RSS feed at {feed}. Please ensure that you got the URL right, and that it is actually an RSS feed.",