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=-1.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,NO_DNS_FOR_FROM, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from [10.7.7.5] (unknown [182.253.183.184]) by gnuweeb.org (Postfix) with ESMTPSA id B7CBB7E3B8; Tue, 3 Jan 2023 07:09:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1672729770; bh=XgLkJYpeT4DUQEgL/r4bIZo2cs+P/q8RmXE6HFKyAVA=; h=Date:To:Cc:References:From:Subject:In-Reply-To:From; b=RDvCecDlOcFEZbipiEUtL2G3eMmLwOSPKgMvfFG7C1dY5RwGuBAW8Wil5fEGTj5dF QKSIk8L2pnw0jQInaDIrTv3CRZuzsI2ePqMFhnT+f7wjw5e99QGqihbk/vjhNnVAlK AGDZayLcXA7rIdz8t02z0fg4u32j/Kn74+dAveb2HDeavp4Zq3fnCiCfxDlr8UlwWF pnI1tYKXQ6Ct/HHr2ymQClocfITsx83ADAumNu/mELgKxn2MM34yi8BO20RUYa9fcD Mt0SavMtyRLIvb1qmn2LjUnPANvG1fcIQdHLx9cizsi+atKEc8w+0JoOzM2zeGufCF A1G54Va6gLP8w== Message-ID: <14a8fceb-7c47-fbc6-b0d2-2e60518363a9@gnuweeb.org> Date: Tue, 3 Jan 2023 14:09:26 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Content-Language: en-US To: Muhammad Rizki Cc: Alviro Iskandar Setiawan , GNU/Weeb Mailing List References: <20230103063641.1680-1-kiizuha@gnuweeb.org> <20230103063641.1680-6-kiizuha@gnuweeb.org> From: Ammar Faizi Subject: Re: [PATCH v1 05/13] feat(telegram): Implement the DaemonException() class In-Reply-To: <20230103063641.1680-6-kiizuha@gnuweeb.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: On 1/3/23 1:36 PM, Muhammad Rizki wrote: > @@ -71,8 +72,9 @@ class Bot(): > 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) You need to handle a non-DaemonException too, because 'get_atom_urls()' may 'raise' an exception that's not instance of these 3: (DaemonException, OperationalError, DatabaseError) Also, please report both, @atom_url and @thread_url. Something like this (just a semi pseudo-code): atom_url = None try: for atom_url in self.db.get_atom_urls(): await self.__handle_atom_url(atom_url) except (OperationalError, DatabaseError) as e: await self.handle_db_error(e) except (TelegramDaemonException) as e: e.set_atom_url(atom_url) await self.client.report_err(e) except e_orig: e = DaemonException() e.set_atom_url(atom_url) e.set_thread_url(None) e.set_message(e_orig) await self.client.report_err(e) // The report_err side class Client(whatnot): def report_err(self, e: DaemonException): # # Send atom_url, thread_url, and orig exception msg # Maybe you're aware of a better design than this. If so, send the better version. -- Ammar Faizi