| 123456789101112131415161718192021222324252627282930313233343536373839 |
- from enum import Enum
- class ErrorCodeEnum(Enum):
- """
- 错误码枚举定义
- """
- SUCCESS = ('100000', '成功')
- ERROR = ('100500', '服务异常')
-
- SESSION_ID_EMPTY = ('100001', '会话ID为空')
- BUSINSESS_SCENE_ERROR = ('100002', '业务场景错误')
- INPUT_INFO_EMPTY = ('100003', '用户输入为空')
- BUSINSESS_SCENE_EMPTY = ('100004', '业务场景为空')
- BUSINSESS_SCENE_PROMPT_FILE_EMPTY = ('100005', '业务场景提示词文件为空')
- BUSINSESS_SCENE_PROMPT_FILE_NOT_EXISTS = ('100006', '业务场景提示词文件不存在')
- BUSINSESS_SCENE_PROMPT_FILE_READ_ERROR = ('100007', '业务场景提示词文件读取异常')
-
- def __init__(self, code : str, desc : str):
- self.code = code
- self.desc = desc
-
- def get_item_by_code(self , code : str):
- """
- 根据code 找枚举项
- """
- for item in list(ErrorCodeEnum):
- if item.code == code:
- return item
- return None
-
- def __str__(self) -> str:
- return self.code + ":" + self.desc
-
|