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 autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.126.135]) by gnuweeb.org (Postfix) with ESMTPSA id 46FE97E427; Sun, 8 Jan 2023 06:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1673158567; bh=aQTOSY3+JUYV8e2KrSvqUJcAeBF4owgz5XMheZCIb2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cPSLVyBfxYIftiKhYndXbUs4Y2OsSMTpFS1kf/JvwuzA/G4ZXI9Ec77+UTf/FRfVB Oi9iqaJEV8UQlNKto4K2SAzYDPlfkYuv145d+OEg6suwyT1S0uDNah5Nh/Tq4nHjVS NaEZYHieCif8jazZSHZQDCmqpfyFsRgQN8NZ4QbgvQWTZoNRLih0IuBMaWNj0Bw7CT sp8WCGydtTEd0HpnKZwPJRy/eGgR6OGxU7KvXt15vZCf9lqJJonfz7lJEbWzUTq2pU Evw+/pr9+9sBH5dahnKUMSAgZsrXwC2mYUwbNUO2HjCHuK2nle/ACv5BnGQ59h9sYC Orwqa7IQ4L2hA== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v2 03/11] Add DaemonException() class Date: Sun, 8 Jan 2023 13:15:35 +0700 Message-Id: <20230108061543.1780-4-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20230108061543.1780-1-kiizuha@gnuweeb.org> References: <20230108061543.1780-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Added DaemonException() class in the daemon/exceptions.py to be able to throw custom error, the use case is to easily catch the email thread URL. This error class is reusable for both Discord and Telegram bot. Signed-off-by: Muhammad Rizki --- daemon/exceptions.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 daemon/exceptions.py diff --git a/daemon/exceptions.py b/daemon/exceptions.py new file mode 100644 index 0000000..34f6823 --- /dev/null +++ b/daemon/exceptions.py @@ -0,0 +1,18 @@ +from typing import Optional + +class DaemonException(Exception): + thread_url: Optional[str] = None + atom_url: Optional[str] = None + original_exception: Optional[str] = None + + def __str__(self) -> str: + return self.original_exception + + def set_atom_url(self, url: str): + self.atom_url = url + + def set_thread_url(self, url: str): + self.thread_url = url + + def set_message(self, msg: str): + self.original_exception = msg -- Muhammad Rizki