2025-07-15 17:13:33 +08:00
|
|
|
|
from nonebot.exception import IgnoredException
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CooldownError(IgnoredException):
|
|
|
|
|
|
"""
|
|
|
|
|
|
冷却异常,用于在冷却时中断事件处理。
|
|
|
|
|
|
继承自 IgnoredException,不会在控制台留下错误堆栈。
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, message: str):
|
|
|
|
|
|
self.message = message
|
|
|
|
|
|
super().__init__(message)
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2025-07-03 17:39:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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}"
|
2025-08-15 16:34:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RenderingError(Exception):
|
|
|
|
|
|
"""
|
|
|
|
|
|
在渲染服务无法生成图片时抛出。
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
pass
|