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,URIBL_BLOCKED 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 54F297E426; Tue, 3 Jan 2023 06:37:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1672727829; bh=TWk7w7wP3KBEYyS6adGhv/PVnKw8fTd7UzVIubWvD3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HFYoF/XhW13+xPB5iJYQxUHezY5RftDj91GZJsn5Va2KuJDQwNWLA4rG1Sfhognot suLqOIFG/px5tmD+BKp1DPs3xGSiGh8+YOIE7reUrVe02FoFvXR+NoL2UqDyk6waQQ 9xeNKrBbzgGEefOQrS0kksJ6tA8QSddqmN4JGxrx36ZGep+9jLBUIJpiB++HVp9JzI lPqf2Gpef7pfE2yUKVjN4CpUI/TGW84uu9DS33K+7koULhPFIjUejhASkdFUn1J7w3 zuLNeQosfir12qmc6NWrPtD0jI/hztKuWHL3a4Y/W1owX6hiJYJlIXEREUXveKwygg IF75OiUA3XO4g== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v1 04/13] feat: add DaemonException() class Date: Tue, 3 Jan 2023 13:36:32 +0700 Message-Id: <20230103063641.1680-5-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20230103063641.1680-1-kiizuha@gnuweeb.org> References: <20230103063641.1680-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 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