mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
✨ 细化异常
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
"""任务没有正常完成处理的错误"""
|
||||
|
||||
Reference in New Issue
Block a user