core_enums.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from enum import Enum
  2. class ErrorCodeEnum(Enum):
  3. """
  4. 错误码枚举定义
  5. """
  6. SUCCESS = ('100000', '成功')
  7. ERROR = ('100500', '服务异常')
  8. SESSION_ID_EMPTY = ('100001', '会话ID为空')
  9. BUSINSESS_SCENE_ERROR = ('100002', '业务场景错误')
  10. INPUT_INFO_EMPTY = ('100003', '用户输入为空')
  11. BUSINSESS_SCENE_EMPTY = ('100004', '业务场景为空')
  12. BUSINSESS_SCENE_PROMPT_FILE_EMPTY = ('100005', '业务场景提示词文件为空')
  13. BUSINSESS_SCENE_PROMPT_FILE_NOT_EXISTS = ('100006', '业务场景提示词文件不存在')
  14. BUSINSESS_SCENE_PROMPT_FILE_READ_ERROR = ('100007', '业务场景提示词文件读取异常')
  15. def __init__(self, code : str, desc : str):
  16. self.code = code
  17. self.desc = desc
  18. def get_item_by_code(self , code : str):
  19. """
  20. 根据code 找枚举项
  21. """
  22. for item in list(ErrorCodeEnum):
  23. if item.code == code:
  24. return item
  25. return None
  26. def __str__(self) -> str:
  27. return self.code + ":" + self.desc