Files
nonebot-plugin-tetris-stats/nonebot_plugin_tetris_stats/utils/exception.py
呵呵です ec392ee384 支持茶服多个api地址的故障转移 (#301)
*  RequestError 新增 status_code 参数

*  新增支持故障转移的请求方法

*  支持茶服多个api地址的故障转移
2024-04-30 01:52:41 +08:00

40 lines
945 B
Python

class TetrisStatsError(Exception):
"""所有 TetrisStats 发生的异常基类"""
def __init__(self, message: str = ''):
self.message = message
def __str__(self) -> str:
return self.message
def __repr__(self) -> str:
return self.message
class NeedCatchError(TetrisStatsError):
"""需要被捕获的异常基类"""
class RequestError(NeedCatchError):
"""请求错误"""
def __init__(self, message: str = '', *, status_code: int | None = None):
super().__init__(message)
self.status_code = status_code
class MessageFormatError(NeedCatchError):
"""用户发送的消息格式不正确"""
class DoNotCatchError(TetrisStatsError):
"""不应该被捕获的异常基类"""
class WhatTheFuckError(DoNotCatchError):
"""用于表示不应该出现的情况 ("""
class HandleNotFinishedError(DoNotCatchError):
"""任务没有正常完成处理的错误"""