2023-06-08 14:03:47 +00:00
|
|
|
class BaseException(Exception):
|
|
|
|
"""Base exception class."""
|
|
|
|
|
|
|
|
message: str = ""
|
|
|
|
|
|
|
|
def __init__(self, message: str | None = None, *args: object) -> None:
|
|
|
|
if message is not None:
|
|
|
|
self.message = message
|
|
|
|
super().__init__(self.message, *args)
|
|
|
|
|
|
|
|
|
|
|
|
class HttpRequestError(BaseException):
|
|
|
|
"""Exception raised when an HTTP request fails."""
|
2023-05-28 13:13:13 +00:00
|
|
|
|
|
|
|
status: int = 0
|
|
|
|
reason: str = ""
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
status: int,
|
|
|
|
reason: str,
|
|
|
|
message: str | None = None,
|
|
|
|
*args: object,
|
|
|
|
) -> None:
|
|
|
|
if not message:
|
|
|
|
message = f"[{status}] {reason}"
|
|
|
|
self.status = status
|
|
|
|
self.reason = reason
|
|
|
|
self.message = message
|
|
|
|
super().__init__(message, *args)
|
2023-06-08 14:03:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UserNotFound(BaseException):
|
|
|
|
"""Exception raised when a user is not found."""
|
|
|
|
|
|
|
|
message = "User not found."
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidParams(BaseException):
|
|
|
|
"""Exception raised when invalid parameters are provided."""
|
|
|
|
|
|
|
|
message: str = "Invalid parameters"
|