import pathlib class nick_in_use(Exception): def __init__(self, nick: str) -> None: super().__init__("Nick \"" + nick + "\" already in use.") class user_is_only_admin(Exception): def __init__(self) -> None: super().__init__("This user is only admin, can not being removed.") class invalid_nick_syntax(Exception): def __init__(self, nick: str, error: Exception) -> None: comment = "Nick \"" + nick + "\" has invalid syntax." comment = comment + "\nError: " + str(error) super().__init__(comment) class resources_directory_not_exists(Exception): def __init__(self, resources: pathlib.Path) -> None: comment = "Resources directory \"" + str(resources) + "\" does " comment = comment + "not exists." super().__init__(comment) class user_is_not_admin(Exception): def __init__(self): super().__init__("To do that action user must be admin.") class invalid_password_syntax(Exception): def __init__(self, password: str, error: Exception) -> None: comment = "Password \"" + password + "\" has invalid syntax." comment = comment + "\nError: " + str(error) super().__init__(comment) class invalid_apikey_syntax(Exception): def __init__(self, apikey: str, error: Exception) -> None: comment = "Api Key \"" + apikey + "\" has invalid syntax." comment = comment + "\nError: " + str(error) super().__init__(comment) class nick_not_exists(Exception): def __init__(self, nick: str) -> None: super().__init__("User with nick \"" + nick + "\" not exists.") class apikey_not_exists(Exception): def __init__(self, apikey: str) -> None: super().__init__("Api Key \"" + apikey + "\" does not exists.") class resources_not_exists(Exception): def __init__(self, target: pathlib.Path) -> None: comment = "Attachment file \"" + str(target) + "\" does not exists." super().__init__(comment) class model_must_being_saved(Exception): def __init__(self, target: object) -> None: comment = "To do that operation, model must being saved.\n" comment = comment + "Dump of the model: \n" + repr(target) super().__init__(comment) class not_exists(Exception): def __init__(self, target: object) -> None: comment = "Can not get identifier of object, which currently " comment = comment + "not exists.\nDump of the object:\n" comment = comment + repr(target) super().__init__(comment) class id_is_invalid(Exception): def __init__(self, id: int) -> None: super().__init__("Id \"" + str(id) + "\" is invalid.") class not_found(Exception): def __init__(self, name: str, **kwargs) -> None: comment = "Can not found " + name + " in database. " if len(kwargs) == 0: super().__init__(comment) return comment = comment + "Searching by: " for argument, value in kwargs.items(): comment = comment + "\"" + argument + "\" = \"" comment = comment + value + "\", " comment = comment[:-2] super().__init__(comment)