add custom exception

This commit is contained in:
Marc Koch 2024-07-04 16:39:37 +02:00
parent 3ee2290ca6
commit b6d4c24352
1 changed files with 8 additions and 0 deletions

8
ntfy/exceptions.py Normal file
View File

@ -0,0 +1,8 @@
class SubscriptionError(Exception):
"""Raised when an error occurs while subscribing to a ntfy topic."""
def __init__(self, http_response: dict) -> None:
self._http_message = http_response
self.message = self._http_message.get("error")
self.code = self._http_message.get("code")
super().__init__(self.message)