zhenxun_bot/zhenxun/utils/exception.py

87 lines
1.4 KiB
Python
Raw Normal View History

2025-07-01 16:56:34 +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-05 16:19:12 +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)
)
2025-07-05 16:32:08 +08:00
return f"All {len(self.urls)} URIs failed:\n{exc_info}"