From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.126.135]) by gnuweeb.org (Postfix) with ESMTPSA id 6BFD27E546; Sun, 8 Jan 2023 06:16:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1673158579; bh=2z8shUtcLvspDBIH8GIY7FjO3EYJmGxuDqt3BcdnMeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lRrt8HsfXrFsaTwW6+ir3miZr0APKO20bH3Ge+OIUqdXPP8fGBruToEUaUgNr7YRV qO8WOe9qeB8vMmBj2/Aq+XP7vk0CJHfpL85QKlcMqIB+rr38NCqp5qQbd7M01bTEHf KzLnCLh44h+uVvSH07VFr2qVRw7hPjvWD46xgsyqZ8hV34hFb7VKvDmHO8MPJuyeAr AY4YrNI32//N5dkRDkx/dVdoVplN6gKmUTpfF27QWmXx0XX7b3eul9PPeLeSFHnCLw MNx0XbUpAZTtt8wzj2h9qbnAG3AtM0wLJrcxidRqPxfkXnZH70BffTliiTVqsYCNzk 5r+41WGQMjX2Q== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v2 08/11] discord: Implement the report_err() and DaemonException() error class Date: Sun, 8 Jan 2023 13:15:40 +0700 Message-Id: <20230108061543.1780-9-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20230108061543.1780-1-kiizuha@gnuweeb.org> References: <20230108061543.1780-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: After creating the `report_err()` function within the `GWClient()` class, implement it in `dscord/mailer/listener.py` to report error logs to the Discord channel. Additionally, also implement the DaemonException() function to handle errors. Signed-off-by: Muhammad Rizki --- daemon/dscord/mailer/listener.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/daemon/dscord/mailer/listener.py b/daemon/dscord/mailer/listener.py index a225f46..dc77ad2 100644 --- a/daemon/dscord/mailer/listener.py +++ b/daemon/dscord/mailer/listener.py @@ -14,6 +14,7 @@ from dscord.gnuweeb import GWClient from atom.scraper import Scraper from atom import utils from enums import Platform +from exceptions import DaemonException class Mutexes: @@ -51,8 +52,14 @@ class Listener: async def __run(self): self.logger.info("Running...") - for url in self.db.get_atom_urls(): - await self.__handle_atom_url(url) + url = None + + try: + for url in self.db.get_atom_urls(): + await self.__handle_atom_url(url) + except DaemonException as e: + e.set_atom_url(url) + await self.client.report_err(e) if not self.isRunnerFixed: self.isRunnerFixed = True @@ -72,9 +79,10 @@ class Listener: mail = await self.scraper.get_email_from_url(url) await self.__handle_mail(url, mail) except: - exc_str = utils.catch_err() - self.client.logger.warning(exc_str) - await self.client.send_log_file(url) + e = DaemonException() + e.set_thread_url(url) + e.set_message(utils.catch_err()) + raise e async def __handle_mail(self, url, mail): -- Muhammad Rizki