26
sms/exceptions.py
Normal file
26
sms/exceptions.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""Exception hierarchy for the voip.ms SMS client."""
|
||||
|
||||
|
||||
class VoipMsError(Exception):
|
||||
"""Base error for any failure talking to the voip.ms API."""
|
||||
|
||||
|
||||
class VoipMsAuthError(VoipMsError):
|
||||
"""Authentication / IP-whitelist problem reported by voip.ms."""
|
||||
|
||||
|
||||
class VoipMsApiError(VoipMsError):
|
||||
"""voip.ms returned a non-success `status` in the response body."""
|
||||
|
||||
def __init__(self, message: str, code: str | None = None) -> None:
|
||||
super().__init__(message)
|
||||
self.code = code
|
||||
|
||||
|
||||
class VoipMsRateLimitError(VoipMsError):
|
||||
"""Local daily-send guard refused the request before it was sent."""
|
||||
|
||||
def __init__(self, message: str, *, limit: int, used_today: int) -> None:
|
||||
super().__init__(message)
|
||||
self.limit = limit
|
||||
self.used_today = used_today
|
||||
Reference in New Issue
Block a user