This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Telegram/classes/errors/holo_user.py

39 lines
1.2 KiB
Python
Raw Permalink Normal View History

2023-01-06 16:49:51 +02:00
"""Exceptions that are meant to be used by HoloUser class
and other modules that handle those exceptions"""
2023-03-09 17:25:06 +02:00
2023-01-06 16:49:51 +02:00
class UserNotFoundError(Exception):
"""HoloUser could not find user with such an ID in database"""
2023-03-09 17:25:06 +02:00
2023-01-06 16:49:51 +02:00
def __init__(self, user, user_id):
self.user = user
self.user_id = user_id
2023-03-09 17:25:06 +02:00
super().__init__(
f"User of type {type(self.user)} with id {self.user_id} was not found"
)
2023-01-06 16:49:51 +02:00
class UserInvalidError(Exception):
2023-03-09 17:25:06 +02:00
"""Provided to HoloUser object is not supported"""
2023-01-06 16:49:51 +02:00
def __init__(self, user):
self.user = user
2023-03-09 17:25:06 +02:00
super().__init__(
f"Could not find HoloUser by using {type(self.user)} as an input type"
)
2023-01-06 16:49:51 +02:00
class LabelTooLongError(Exception):
def __init__(self, label: str) -> None:
self.label = label
2023-03-09 17:25:06 +02:00
super().__init__(
f"Could not set label to '{label}' because it is {len(label)} characters long (16 is maximum)"
)
2023-01-06 16:49:51 +02:00
class LabelSettingError(Exception):
def __init__(self, exp: Exception, trace: str) -> None:
2023-03-09 17:25:06 +02:00
super().__init__(
f"❌ **Could not set label**\n\nException: `{exp}`\n\n**Traceback:**\n```\n{trace}\n```"
)