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.2] (unknown [182.253.183.90]) by gnuweeb.org (Postfix) with ESMTPSA id EDD9481134; Sun, 30 Oct 2022 12:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1667133926; bh=2cc+/nFxN7ypIc3iiGRJps8meH7wUe8ADwyxDgP1LH0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=jtg03/czm6KeQYM5F3G4Y31aDW4q4j5ZK35vNtw9kH+KeivJpFKNSuC01WAzflPIq StVCe1iWTFB5e38TxW+1uXJhp+m4sblVDQYKYlrlmOir/teApwsJI0qfra4Wz8TQxz jyhuxFR0lx3mDnC4sakP2IAlk1PT8pSIz8+547FcHxkou22KL8Zqb2bNP+W8tfWhuN MJholvjs6z1DhL2abU3oh1BsFzZm6Q9+rNMYzzl2XW/EnB0sXY+KFkVn4Knh+RMi4W mGPrssP3j7CKuOl3IQxTOJgjM/6/CbD1UjKJrn3pwMqiBuOiT2GJ5ixfhXwd2ly2ty /2+mPpFc4oI1g== Message-ID: <63bd47a2-54f0-28f4-c7a7-08e637d0a995@gnuweeb.org> Date: Sun, 30 Oct 2022 19:45:22 +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 Content-Language: en-US To: Muhammad Rizki , GNU/Weeb Mailing List Cc: Alviro Iskandar Setiawan References: <20221030054930.573374-1-ammarfaizi2@gnuweeb.org> <20221030054930.573374-3-ammarfaizi2@gnuweeb.org> <0feebc01-6965-34eb-468c-25bd90a77605@gnuweeb.org> From: Ammar Faizi In-Reply-To: <0feebc01-6965-34eb-468c-25bd90a77605@gnuweeb.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: On 10/30/22 4:49 PM, Muhammad Rizki wrote: > On 30/10/22 12.49, Ammar Faizi wrote: I didn't write that. Don't change the quotation anyway. >> +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? Looks fine to me, will send a v3 with your changes applied. Thanks. -- Ammar Faizi