From 99aea311a06c9da2a4f9a31232a114e42c6738e0 Mon Sep 17 00:00:00 2001 From: YousefEZ <45167695+YousefEZ@users.noreply.github.com> Date: Wed, 25 Sep 2024 16:47:03 +0100 Subject: [PATCH] :loud_sound: add logging --- view/notifications.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/view/notifications.py b/view/notifications.py index 50fef29..c3dc652 100644 --- a/view/notifications.py +++ b/view/notifications.py @@ -26,11 +26,17 @@ def display_notification(self, notification: ScheduledNotification) -> None: async def render(self, notification: host.notifier.Notification) -> None: logging.debug("[NOTIFICATION][SENDING] UserId=%s", notification.user_id) - user = await self.bot.fetch_user(notification.user_id) - await user.send( - **self._renderer.render("notification", keywords={"notification": notification}).dict() - ) - logging.debug("[NOTIFICATION][SENT] UserId=%s", notification.user_id) + try: + user = await self.bot.fetch_user(notification.user_id) + await user.send( + **self._renderer.render( + "notification", keywords={"notification": notification} + ).dict() + ) + except Exception as e: + logging.error("[NOTIFICATION][ERROR] UserId=%s, Error=%s", notification.user_id, e) + else: + logging.debug("[NOTIFICATION][SENT] UserId=%s", notification.user_id) def start(self) -> None: self.notifier.start()