aboutsummaryrefslogtreecommitdiff
path: root/services/manager/_error.py
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-02-23 16:40:32 +0800
committerYuqian Yang <crupest@crupest.life>2025-02-23 16:40:32 +0800
commit8d85090fc6a41aaa9366250982e41a5534bed283 (patch)
tree22051ae36ba29c25121257ef4ca5fe69fc107e87 /services/manager/_error.py
parent687ae968e10e1738c105fc0538fc29ccb08bfbbf (diff)
downloadcrupest-8d85090fc6a41aaa9366250982e41a5534bed283.tar.gz
crupest-8d85090fc6a41aaa9366250982e41a5534bed283.tar.bz2
crupest-8d85090fc6a41aaa9366250982e41a5534bed283.zip
feat(python): move python codes.
Diffstat (limited to 'services/manager/_error.py')
-rw-r--r--services/manager/_error.py89
1 files changed, 0 insertions, 89 deletions
diff --git a/services/manager/_error.py b/services/manager/_error.py
deleted file mode 100644
index e53c787..0000000
--- a/services/manager/_error.py
+++ /dev/null
@@ -1,89 +0,0 @@
-from __future__ import annotations
-
-from typing import NoReturn, cast, overload
-
-
-class CruException(Exception):
- """Base exception class of all exceptions in cru."""
-
- @overload
- def __init__(
- self,
- message: None = None,
- *args,
- user_message: str,
- **kwargs,
- ): ...
-
- @overload
- def __init__(
- self,
- message: str,
- *args,
- user_message: str | None = None,
- **kwargs,
- ): ...
-
- def __init__(
- self,
- message: str | None = None,
- *args,
- user_message: str | None = None,
- **kwargs,
- ):
- if message is None:
- message = user_message
-
- super().__init__(
- message,
- *args,
- **kwargs,
- )
- self._message: str
- self._message = cast(str, message)
- self._user_message = user_message
-
- @property
- def message(self) -> str:
- return self._message
-
- def get_user_message(self) -> str | None:
- return self._user_message
-
- def get_message(self, use_user: bool = True) -> str:
- if use_user and self._user_message is not None:
- return self._user_message
- else:
- return self._message
-
- @property
- def is_internal(self) -> bool:
- return False
-
- @property
- def is_logic_error(self) -> bool:
- return False
-
-
-class CruLogicError(CruException):
- """Raised when a logic error occurs."""
-
- @property
- def is_logic_error(self) -> bool:
- return True
-
-
-class CruInternalError(CruException):
- """Raised when an internal error occurs."""
-
- @property
- def is_internal(self) -> bool:
- return True
-
-
-class CruUnreachableError(CruInternalError):
- """Raised when a code path is unreachable."""
-
-
-def cru_unreachable() -> NoReturn:
- raise CruUnreachableError("Code should not reach here!")