exception.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. class validator_exception(Exception):
  2. def __init__(self, name: str) -> None:
  3. super().__init__("Invalid property names: " + name + ".")
  4. class exists_exception(Exception):
  5. def __init__(self, name: str) -> None:
  6. super().__init__("Item with this " + name + " already in database.")
  7. class bad_request_exception(Exception):
  8. def __init__(self, content: str) -> None:
  9. super().__init__("Bad request: " + content + ".")
  10. class not_found_exception(Exception):
  11. def __init__(self) -> None:
  12. super().__init__("Not found required target.")
  13. class not_ready_exception(Exception):
  14. def __init__(self, target: any) -> None:
  15. dump = str(target)
  16. what = str(type(target))
  17. info = "Can not work, because " + what + " is not raeady.\n"
  18. info = info + "Dump:\n" + what + "\n\n"
  19. super().__init__(info)
  20. class in_collection_exception(Exception):
  21. pass
  22. class config_exception(Exception):
  23. pass
  24. class access_denied_exception(Exception):
  25. def __init__(self) -> None:
  26. super().__init__("Being logged in is required to access this.")
  27. class image_exception(Exception):
  28. def __init__(self) -> None:
  29. super().__init__("This is not property image file.")
  30. class directory_image_exception(Exception):
  31. pass
  32. class autoadder_exception(Exception):
  33. pass
  34. class image_save_exception(Exception):
  35. def __init__(self, before: Exception) -> None:
  36. super().__init__("Can not save image: " + str(before))
  37. class incomplete_request_exception(Exception):
  38. def __init__(self, name: str) -> None:
  39. content = "Request is not complete. This endpoint require "
  40. content = content + "\"" + name + "\"."
  41. super().__init__(content)
  42. class reservation_exception(Exception):
  43. pass
  44. class empty_field_exception(Exception):
  45. def __init__(self, name: str) -> None:
  46. super().__init__("Field " + name + " is empty. Fill it.")
  47. class reservation_loader_exception(Exception):
  48. pass
  49. class database_exception(Exception):
  50. def __init__(self) -> None:
  51. super().__init__("Database can not commit changes.")
  52. class incorrect_target_exception(Exception):
  53. pass