exceptions.py 1.5 KB

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