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 EDB757E5EA; Sun, 8 Jan 2023 08:08:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1673165285; bh=4O3eCI1XGbPUFTeCrEnaA6Y3LAi+MUreRsG/4BOr2us=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B2M4ZWdAEvW1O2UwhBANEbf9pg3kvJrjJcpRzpyGAljRFipWhM9B66BYEzY4PjHWq DyjL10KAMG6+pfeK2paWAgLFqlJp30PcVCpN8vfjw6RpPk/HmR5rPMtyieuTlJzPCD Vuo5SoYmgcrP+yaJblF6S6KAnzRbciEAwE4zwMDYpuj8gJWQYPc5XQtuuuLLcyLsLq xsQWS4DjrGLctU2g6uq/rd2REz44jnxO/CWJZSxY8x7SjDr2EjDXw2VJYh3QpYxQs/ VAoFSBXOmFJUqbRjLnHJNzluVhHz++St0Wl5H/lt63EWN9svMi3yJoMr3f3DFyreOJ OS1dVnL1oUIEg== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v3 03/11] Add DaemonException() class Date: Sun, 8 Jan 2023 15:07:33 +0700 Message-Id: <20230108080741.1914-4-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20230108080741.1914-1-kiizuha@gnuweeb.org> References: <20230108080741.1914-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Add 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