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 [192.168.1.2] (unknown [101.128.126.183]) by gnuweeb.org (Postfix) with ESMTPSA id D58A281134; Sun, 30 Oct 2022 09:50:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1667123404; bh=9czRPKK6s3wyRoe+dbYcNYNd/PhKRMZyMURYW49HYas=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=fJXazAo/hhJI3caT64soYgrHweBPQHpf3/htXJtCSmRlSnxtDa1ergm67zCbmrNPy B7Qlit/ETmthDoU+REp5ZCrAuYBbG9j6Xc5nspbcD1R/tUMJrGcvW0ls3O1SycbbXE F1PVplUi5kt9BVPJ6X2L3S7r092aBOeE5CUo0eIxj/I1+tWBvIuoKNhCKaZW3PGSDX UHSH35jdUIy0KHuaDj8W/x4BX85+4vS+kizda3dic/Y6DW7+cKO6Ed/sb4YLOuFtmc eAct0CbXyC4nqv0EKgqdl4YrpDyMBXruX0XGr4oksInwNoqDbOPMbmsA6GmSulN5Ux BtZ8wwHYHtMoQ== Message-ID: <0feebc01-6965-34eb-468c-25bd90a77605@gnuweeb.org> Date: Sun, 30 Oct 2022 16:49:58 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v2 2/2] daemon: telegram: Handle MySQL error To: Ammar Faizi , GNU/Weeb Mailing List Cc: Alviro Iskandar Setiawan References: <20221030054930.573374-1-ammarfaizi2@gnuweeb.org> <20221030054930.573374-3-ammarfaizi2@gnuweeb.org> Content-Language: en-US From: Muhammad Rizki In-Reply-To: <20221030054930.573374-3-ammarfaizi2@gnuweeb.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: On 30/10/22 12.49, Ammar Faizi wrote: > +from mysql.connector.errors import OperationalError, DatabaseError > + > + > async def __run(self): > print("[__run]: Running...") > - for url in self.db.get_atom_urls(): > - try: > + try: > + for url in self.db.get_atom_urls(): > await self.__handle_atom_url(url) > - except: > - print(traceback.format_exc()) > + except (OperationalError, DatabaseError) as e: > + await self.handle_db_error(e) I prefer to do it like this way. What do you think?