exceptions.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import pathlib
  2. class nick_in_use(Exception):
  3. def __init__(self, nick: str) -> None:
  4. super().__init__("Nick \"" + nick + "\" already in use.")
  5. class user_is_only_admin(Exception):
  6. def __init__(self) -> None:
  7. super().__init__("This user is only admin, can not being removed.")
  8. class invalid_nick_syntax(Exception):
  9. def __init__(self, nick: str, error: Exception) -> None:
  10. comment = "Nick \"" + nick + "\" has invalid syntax."
  11. comment = comment + "\nError: " + str(error)
  12. super().__init__(comment)
  13. class resources_directory_not_exists(Exception):
  14. def __init__(self, resources: pathlib.Path) -> None:
  15. comment = "Resources directory \"" + str(resources) + "\" does "
  16. comment = comment + "not exists."
  17. super().__init__(comment)
  18. class user_is_not_admin(Exception):
  19. def __init__(self):
  20. super().__init__("To do that action user must be admin.")
  21. class invalid_password_syntax(Exception):
  22. def __init__(self, password: str, error: Exception) -> None:
  23. comment = "Password \"" + password + "\" has invalid syntax."
  24. comment = comment + "\nError: " + str(error)
  25. super().__init__(comment)
  26. class invalid_apikey_syntax(Exception):
  27. def __init__(self, apikey: str, error: Exception) -> None:
  28. comment = "Api Key \"" + apikey + "\" has invalid syntax."
  29. comment = comment + "\nError: " + str(error)
  30. super().__init__(comment)
  31. class nick_not_exists(Exception):
  32. def __init__(self, nick: str) -> None:
  33. super().__init__("User with nick \"" + nick + "\" not exists.")
  34. class apikey_not_exists(Exception):
  35. def __init__(self, apikey: str) -> None:
  36. super().__init__("Api Key \"" + apikey + "\" does not exists.")
  37. class resources_not_exists(Exception):
  38. def __init__(self, target: pathlib.Path) -> None:
  39. comment = "Attachment file \"" + str(target) + "\" does not exists."
  40. super().__init__(comment)