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.57]) by gnuweeb.org (Postfix) with ESMTPSA id 1521A7E317; Tue, 19 Jul 2022 00:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1658189894; bh=m25oUArpxqxIo7X0IyRQaNi95KBkTmacVQ2F48AtZkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RkMJMI9Na+iYBOTPNl53im8pENKrvz249dlEJvmw4MzNHbI6nSPM/4XZ7XZOJ9TCI X4lqWxk39wzr/8nHoanTmoK2FtFmYphtf/jk1NIUvJ46Yh9Z0hPexu5u4Ql/2TcwR8 /Xk0nXBHhJl9wofX1kVYCZdzCmn2XUcbhMRVht8BcnzozFbLiubZxU06m9pUvVt1GJ Ae3AbdqUEfotII0tr5z6ViCfCkWse4+EHun4YPU2qPqb29xgiGd12uCDNcWChn+KPE ahHqJZ8HnlZ3HkE2Cupz/9PLfYaBLArvpOFo3f0rZyYXNJFoPUjLKXceXh9jZZcWlf BPt9N6LzHDsPg== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , GNU/Weeb Mailing List Subject: [PATCH v2 06/18] daemon: Use traceback.format_exc() to get the error detail Date: Tue, 19 Jul 2022 07:17:32 +0700 Message-Id: <20220719001744.1950-7-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220719001744.1950-1-kiizuha@gnuweeb.org> References: <20220719001744.1950-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