zhenxun_bot/zhenxun/utils/exception.py

109 lines
1.8 KiB
Python
Raw Normal View History

from nonebot.exception import IgnoredException
class CooldownError(IgnoredException):
"""
冷却异常用于在冷却时中断事件处理
继承自 IgnoredException不会在控制台留下错误堆栈
"""
def __init__(self, message: str):
self.message = message
super().__init__(message)
:sparkles: 首次启动时提供使用web ui方式完全配置 (#1870) * :sparkles: 添加全局优先级hook * :sparkles: 添加基础配置api * :sparkles: 添加数据库连接测试 * :speech_balloon: 提示重启 * :adhesive_bandage: 填充过配置时友好提示 * :bug: 首次生成简易配置后自动加载 * :sparkles: 添加配置后重启接口 * :sparkles: 添加重启标志文件 * :sparkles: 添加重启脚本命令 * :sparkles: 添加重启系统限制 * :sparkles: 首次配置判断是否为win系统 * :fire: 移除bat * :sparkles: 添加关于菜单 * :sparkles: 支持整合包插件安装和添加整合包文档 * :adhesive_bandage: 检测数据库路径 * :adhesive_bandage: 修改数据库路径检测 * :adhesive_bandage: 修改数据库路径检测 * :adhesive_bandage: 修复路径注入 * :art: 显示添加优先级 * :bug: 修改PriorityLifecycle字典类名称 * :zap: 修复路径问题 * :zap: 修复路径检测 * ✨ 新增路径验证功能,确保用户输入的路径安全并在项目根目录内 * ✨ 优化路径验证功能,增加对非法字符和路径长度的检查,确保用户输入的路径更加安全 * :rotating_light: auto fix by pre-commit hooks * ✨ 优化获取文件列表的代码格式 * :memo: 修改README中webui示例图 * ✨ 更新PriorityLifecycle.on_startup装饰器 * ✨ 简化安装依赖的命令构建逻辑 * :rotating_light: auto fix by pre-commit hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-06-16 09:11:41 +08:00
class HookPriorityException(BaseException):
"""
钩子优先级异常
"""
def __init__(self, info: str = "") -> None:
self.info = info
def __str__(self) -> str:
return self.info
2024-02-04 04:18:54 +08:00
class NotFoundError(Exception):
2024-02-26 03:04:32 +08:00
"""
未发现
"""
2024-02-04 04:18:54 +08:00
pass
2024-02-25 03:18:34 +08:00
class GroupInfoNotFound(Exception):
2024-02-26 03:04:32 +08:00
"""
群组未找到
"""
2024-02-25 03:18:34 +08:00
pass
class EmptyError(Exception):
2024-02-26 03:04:32 +08:00
"""
空错误
"""
2024-02-25 03:18:34 +08:00
pass
class UserAndGroupIsNone(Exception):
2024-02-26 03:04:32 +08:00
"""
用户和群组为空
"""
pass
class InsufficientGold(Exception):
"""
金币不足
"""
2024-02-25 03:18:34 +08:00
pass
2024-05-20 22:03:11 +08:00
class NotFindSuperuser(Exception):
"""
未找到超级用户
"""
pass
2024-08-16 19:54:58 +08:00
class GoodsNotFound(Exception):
"""
或找到道具
"""
pass
class AllURIsFailedError(Exception):
"""
当所有备用URL都尝试失败后抛出此异常
"""
def __init__(self, urls: list[str], exceptions: list[Exception]):
self.urls = urls
self.exceptions = exceptions
super().__init__(
f"All {len(urls)} URIs failed. Last exception: {exceptions[-1]}"
)
def __str__(self) -> str:
exc_info = "\n".join(
f" - {url}: {exc.__class__.__name__}({exc})"
for url, exc in zip(self.urls, self.exceptions)
)
return f"All {len(self.urls)} URIs failed:\n{exc_info}"
class RenderingError(Exception):
"""
在渲染服务无法生成图片时抛出
"""
pass