exceptions.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """LearningAgent 自定义异常类"""
  2. class LearningAgentError(Exception):
  3. """基础异常类"""
  4. pass
  5. class DomainNotFoundError(LearningAgentError):
  6. """领域不存在"""
  7. def __init__(self, domain: str):
  8. self.domain = domain
  9. super().__init__(f"领域 '{domain}' 不存在。请先使用 /create 创建学习计划。")
  10. class FileReadError(LearningAgentError):
  11. """文件读取失败"""
  12. def __init__(self, message: str):
  13. super().__init__(f"文件读取失败:{message}")
  14. class FileWriteError(LearningAgentError):
  15. """文件写入失败"""
  16. def __init__(self, message: str):
  17. super().__init__(f"文件写入失败:{message}")
  18. class LLMError(LearningAgentError):
  19. """LLM 调用失败"""
  20. def __init__(self, message: str):
  21. super().__init__(f"AI服务错误:{message}")
  22. class InvalidInputError(LearningAgentError):
  23. """无效输入"""
  24. def __init__(self, message: str):
  25. super().__init__(f"无效输入:{message}")