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,URIBL_BLOCKED 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 1CE2A7E3B8; Tue, 3 Jan 2023 06:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1672727847; bh=AkhfeKNMV66hUqThXt0h3YPXIv/TUpIYPpddpwzZVw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qsdjsnug6cBkHXCjYXGOii/ymkhvEzZ42l8KAJRWM89CUzGLsa1GJiHM4fz2LOqPR cSK3aPMbnimDqUO1blhobNEzHm619SMfsFgvuS+ySwOCi8XZwjt7DywVndERC2BRBb 5k/ZX4IvqVtBwCUUWXWVFXbt3Tw2wErpVavfIfCqj8WWqM/aj+cvQyCUx4I0AS8iv6 KR7uGQPT6YmP5NDyrTrSdx5AjT65bvGCOP5DUXs46B7rqT3nEFoZEcdrpPm6vRGY36 yUw8FfKXmY0Gi45b1tYhDdb1ZgDGn27Ag6E9qdYHiT98mvBLGTph4yssWNxD4+d61s OuRB9zAhHXTAA== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v1 12/13] feat(discord): Implement the DaemonException for handle error Date: Tue, 3 Jan 2023 13:36:40 +0700 Message-Id: <20230103063641.1680-13-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20230103063641.1680-1-kiizuha@gnuweeb.org> References: <20230103063641.1680-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This custom error class is used to catch errors and save information such as the email thread URL, atom URL, and exception message. The purpose of saving this information is to report the error with the thread URL for easily debugging. Signed-off-by: Muhammad Rizki --- daemon/dscord/mailer/listener.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/daemon/dscord/mailer/listener.py b/daemon/dscord/mailer/listener.py index 2bde0f0..e55a4fc 100644 --- a/daemon/dscord/mailer/listener.py +++ b/daemon/dscord/mailer/listener.py @@ -15,6 +15,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: @@ -77,8 +78,9 @@ class Listener: await self.__handle_atom_url(url) except (OperationalError, DatabaseError) as e: await self.handle_db_error(e) - except: - await self.client.report_err(url) + except DaemonException as e: + e.set_atom_url(url) + await self.client.report_err(e.thread_url) if not self.isRunnerFixed: self.isRunnerFixed = True @@ -98,8 +100,10 @@ class Listener: mail = await self.scraper.get_email_from_url(url) await self.__handle_mail(url, mail) except: - # this statement will be changed in the next commit - await self.client.report_err(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