From d59bccbd4dae49ca9ede83ea30cd812125f5c8f1 Mon Sep 17 00:00:00 2001 From: scdhh Date: Wed, 29 Nov 2023 11:29:46 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E7=BB=86=E5=8C=96=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io_data_processor/__init__.py | 8 ++++---- .../top_data_processor/__init__.py | 8 ++++---- .../tos_data_processor/__init__.py | 10 +++++----- nonebot_plugin_tetris_stats/utils/exception.py | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/nonebot_plugin_tetris_stats/game_data_processor/io_data_processor/__init__.py b/nonebot_plugin_tetris_stats/game_data_processor/io_data_processor/__init__.py index be8dcd3..4a1b524 100644 --- a/nonebot_plugin_tetris_stats/game_data_processor/io_data_processor/__init__.py +++ b/nonebot_plugin_tetris_stats/game_data_processor/io_data_processor/__init__.py @@ -9,7 +9,7 @@ from nonebot_plugin_orm import get_session from sqlalchemy import func, select from ...db import query_bind_info -from ...utils.exception import NeedCatchError +from ...utils.exception import HandleNotFinishedError, NeedCatchError from ...utils.metrics import get_metrics from ...utils.platform import get_platform from ...utils.typing import Me @@ -94,7 +94,7 @@ async def _(bot: Bot, event: Event, matcher: Matcher, account: User): await matcher.send(await proc.handle_bind(platform=get_platform(bot), account=event.get_user_id())) except NeedCatchError as e: await matcher.send(str(e)) - raise + raise HandleNotFinishedError from e @alc.assign('query') @@ -118,7 +118,7 @@ async def _(bot: Bot, event: Event, matcher: Matcher, target: At | Me): await matcher.send(message + await proc.handle_query()) except NeedCatchError as e: await matcher.send(str(e)) - raise + raise HandleNotFinishedError from e @alc.assign('query') @@ -132,7 +132,7 @@ async def _(event: Event, matcher: Matcher, account: User): await matcher.send(await proc.handle_query()) except NeedCatchError as e: await matcher.send(str(e)) - raise + raise HandleNotFinishedError from e @alc.assign('rank') diff --git a/nonebot_plugin_tetris_stats/game_data_processor/top_data_processor/__init__.py b/nonebot_plugin_tetris_stats/game_data_processor/top_data_processor/__init__.py index a34ccc9..87b4eeb 100644 --- a/nonebot_plugin_tetris_stats/game_data_processor/top_data_processor/__init__.py +++ b/nonebot_plugin_tetris_stats/game_data_processor/top_data_processor/__init__.py @@ -5,7 +5,7 @@ from nonebot_plugin_alconna import At, on_alconna from nonebot_plugin_orm import get_session from ...db import query_bind_info -from ...utils.exception import NeedCatchError +from ...utils.exception import HandleNotFinishedError, NeedCatchError from ...utils.platform import get_platform from ...utils.typing import Me from .. import add_default_handlers @@ -77,7 +77,7 @@ async def _(bot: Bot, event: Event, matcher: Matcher, account: User): await matcher.send(await proc.handle_bind(platform=get_platform(bot), account=event.get_user_id())) except NeedCatchError as e: await matcher.send(str(e)) - raise + raise HandleNotFinishedError from e @alc.assign('query') @@ -101,7 +101,7 @@ async def _(bot: Bot, event: Event, matcher: Matcher, target: At | Me): await matcher.send(message + await proc.handle_query()) except NeedCatchError as e: await matcher.send(str(e)) - raise + raise HandleNotFinishedError from e @alc.assign('query') @@ -115,7 +115,7 @@ async def _(event: Event, matcher: Matcher, account: User): await matcher.send(await proc.handle_query()) except NeedCatchError as e: await matcher.send(str(e)) - raise + raise HandleNotFinishedError from e add_default_handlers(alc) diff --git a/nonebot_plugin_tetris_stats/game_data_processor/tos_data_processor/__init__.py b/nonebot_plugin_tetris_stats/game_data_processor/tos_data_processor/__init__.py index 2fee1de..f34c864 100644 --- a/nonebot_plugin_tetris_stats/game_data_processor/tos_data_processor/__init__.py +++ b/nonebot_plugin_tetris_stats/game_data_processor/tos_data_processor/__init__.py @@ -5,7 +5,7 @@ from nonebot_plugin_alconna import At, on_alconna from nonebot_plugin_orm import get_session from ...db import query_bind_info -from ...utils.exception import NeedCatchError +from ...utils.exception import HandleNotFinishedError, NeedCatchError from ...utils.platform import get_platform from ...utils.typing import Me from .. import add_default_handlers @@ -87,7 +87,7 @@ try: await matcher.send(await proc.handle_query()) except NeedCatchError as e: await matcher.send(str(e)) - raise + raise HandleNotFinishedError from e except ImportError: pass @@ -103,7 +103,7 @@ async def _(bot: Bot, event: Event, matcher: Matcher, account: User): await matcher.send(await proc.handle_bind(platform=get_platform(bot), account=event.get_user_id())) except NeedCatchError as e: await matcher.send(str(e)) - raise + raise HandleNotFinishedError from e @alc.assign('query') @@ -127,7 +127,7 @@ async def _(bot: Bot, event: Event, matcher: Matcher, target: At | Me): await matcher.send(message + await proc.handle_query()) except NeedCatchError as e: await matcher.send(str(e)) - raise + raise HandleNotFinishedError from e @alc.assign('query') @@ -141,7 +141,7 @@ async def _(event: Event, matcher: Matcher, account: User): await matcher.send(await proc.handle_query()) except NeedCatchError as e: await matcher.send(str(e)) - raise + raise HandleNotFinishedError from e add_default_handlers(alc) diff --git a/nonebot_plugin_tetris_stats/utils/exception.py b/nonebot_plugin_tetris_stats/utils/exception.py index f72a089..26722b9 100644 --- a/nonebot_plugin_tetris_stats/utils/exception.py +++ b/nonebot_plugin_tetris_stats/utils/exception.py @@ -15,10 +15,6 @@ class NeedCatchError(TetrisStatsError): """需要被捕获的异常基类""" -class DoNotCatchError(TetrisStatsError): - """不应该被捕获的异常基类""" - - class RequestError(NeedCatchError): """请求错误""" @@ -27,9 +23,13 @@ class MessageFormatError(NeedCatchError): """用户发送的消息格式不正确""" -class DatabaseVersionError(DoNotCatchError): - """数据库版本错误""" +class DoNotCatchError(TetrisStatsError): + """不应该被捕获的异常基类""" class WhatTheFuckError(DoNotCatchError): """用于表示不应该出现的情况 (""" + + +class HandleNotFinishedError(DoNotCatchError): + """任务没有正常完成处理的错误"""