refactor: add error util in project

This commit is contained in:
2025-11-11 21:50:15 +08:00
parent 7a189eb631
commit c99b324b81

23
src/utils/error.py Normal file
View File

@@ -0,0 +1,23 @@
from typing import Protocol
class error(Protocol):
_error_code: int = 0
_error_info: str = ""
def __init__(self, error_code: int, error_info: str):
self._error_code = error_code
self._error_info = error_info
def __str__(self) -> str:
return f"{self.__class__.__name__}({self._error_code}, {self._error_info})"
@property
def error_code(self) -> int:
return self._error_code
@property
def error_info(self) -> str:
return self._error_info
@property
def is_success(self) -> bool:
return self._error_code == 0