exceptions.py 954 B

1234567891011121314151617181920212223242526272829
  1. import pathlib
  2. from .file import file
  3. from .command import command
  4. class abstract(TypeError):
  5. def __init__(self) -> None:
  6. super().__init__("This is abstract function.")
  7. class not_exists(RuntimeError):
  8. def __init__(self, target: pathlib.Path) -> None:
  9. super().__init__("File \"" + str(target) + "\" not exists.")
  10. class already_packed(RuntimeError):
  11. def __init__(self, target: file) -> None:
  12. super().__init__(
  13. "File for \"" + target.path_name + "\" already packed."
  14. )
  15. class broken_package(RuntimeError):
  16. def __init__(self, error: Exception) -> None:
  17. super().__init__("Can not unpack broken package.\n" + str(error))
  18. class not_readable(Exception):
  19. def __init__(self, target: pathlib.Path, error: Exception) -> None:
  20. super().__init__(
  21. "File \"" + str(target) + "\" can not being read. " \
  22. + "Because of \"" + str(error) + "\" exception."
  23. )