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.125.94]) by gnuweeb.org (Postfix) with ESMTPSA id 061037FE95; Thu, 21 Jul 2022 23:30:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1658446208; bh=m25oUArpxqxIo7X0IyRQaNi95KBkTmacVQ2F48AtZkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GhI6fqgHn7nJrWP+dtIQ2zhKYm7VzFMpYFlqbfrguB1w3ydeAdgf5JKgb0pbfIrMH 0EZxwPTgtANqRnt+r7EPjkJ/R7jBkgojrF8adxHkA+maSDG+w55cZOSzfJJPskAOQk 2RRQufOMa0Cq3+mFx9j1Et/cfIykZj8k8a1YSo2mZ3e59VGtr1UIw2oZ335KLS/dsM GGyqXScT81+4Iha4EQfWh0HN3FmzhRo8nucoG+f5GT9Gcf+P26TREu/gCveo6v31Df t7LrF1WYmXCi6/OhAnuuIP9YBAtQd9DDJrHEMTV4TSrK4SpJKTXsF8xSbxtGXq03GO b/7fiGGfXqGtA== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , GNU/Weeb Mailing List Subject: [PATCH v3 06/17] daemon: Use traceback.format_exc() to get the error detail Date: Fri, 22 Jul 2022 06:29:27 +0700 Message-Id: <20220721232938.503-7-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220721232938.503-1-kiizuha@gnuweeb.org> References: <20220721232938.503-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: From: Muhammad Rizki `print(f"[__run]: Error: {e}")` doesn't give enough information for debugging because it doesn't show the traceback, files, line numbers, etc. It only shows the error message raised by an exception. This is severely lacking and very bad for debugging experience. Use `traceback.format_exc()` instead to get a better log because it shows a complete traceback of the error. Signed-off-by: Muhammad Rizki --- daemon/scraper/bot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/daemon/scraper/bot.py b/daemon/scraper/bot.py index 04caab6..2392b61 100644 --- a/daemon/scraper/bot.py +++ b/daemon/scraper/bot.py @@ -17,6 +17,7 @@ import pyrogram import asyncio import shutil import re +import traceback class BotMutexes(): @@ -63,8 +64,8 @@ class Bot(): for url in self.ATOM_URLS: try: await self.__handle_atom_url(url) - except Exception as e: - print(f"[__run]: Error: {e}") + except: + print(traceback.format_exc()) if not self.isRunnerFixed: self.isRunnerFixed = True -- Muhammad Rizki