front/xhs-agent-desktop/engine/scripts/xhs/errors.py
zzh 5a26ae0048 feat: 小红书模块迁移、登录重构与 xhs-agent-desktop 桌面 Agent
- 新增小红书前端模块(启动服务、内容分析、爆款创作、发布记录、技能卡片、拟人设置、AI 助手)

- 新增 xhs-agent-desktop 独立桌面 Agent,对接 OMS 任务调度

- 登录页重构,整合微信登录与 OMS JWT 认证

- 订单、渠道、用户中心等页面与 API 增强

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 16:13:13 +08:00

94 lines
2.3 KiB
Python

"""小红书自动化异常体系。"""
class XHSError(Exception):
"""小红书自动化基础异常。"""
class NoFeedsError(XHSError):
"""没有捕获到 feeds 数据。"""
def __init__(self) -> None:
super().__init__("没有捕获到 feeds 数据")
class BrowseCancelledError(XHSError):
"""用户请求停止浏览采集。"""
def __init__(self, message: str = "用户已停止采集") -> None:
super().__init__(message)
class BrowseTargetReached(XHSError):
"""已采集达到本次随机目标数量。"""
def __init__(self) -> None:
super().__init__("已达本次采集目标数量")
class NoFeedDetailError(XHSError):
"""没有捕获到 feed 详情数据。"""
def __init__(self) -> None:
super().__init__("没有捕获到 feed 详情数据")
class NotLoggedInError(XHSError):
"""未登录。"""
def __init__(self) -> None:
super().__init__("未登录,请先扫码登录")
class PageNotAccessibleError(XHSError):
"""页面不可访问。"""
def __init__(self, reason: str) -> None:
self.reason = reason
super().__init__(f"笔记不可访问: {reason}")
class UploadTimeoutError(XHSError):
"""上传超时。"""
class PublishError(XHSError):
"""发布失败。"""
class TitleTooLongError(PublishError):
"""标题超过长度限制。"""
def __init__(self, current: str, maximum: str) -> None:
self.current = current
self.maximum = maximum
super().__init__(f"当前输入长度为{current},最大长度为{maximum}")
class ContentTooLongError(PublishError):
"""正文超过长度限制。"""
def __init__(self, current: str, maximum: str) -> None:
self.current = current
self.maximum = maximum
super().__init__(f"当前输入长度为{current},最大长度为{maximum}")
class RateLimitError(XHSError):
"""请求频率过高,验证码获取失败。"""
def __init__(self) -> None:
super().__init__("请求太频繁,验证码获取失败,请重启浏览器后重试")
class CDPError(XHSError):
"""CDP 通信异常。"""
class ElementNotFoundError(XHSError):
"""页面元素未找到。"""
def __init__(self, selector: str) -> None:
self.selector = selector
super().__init__(f"未找到元素: {selector}")