mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
Merge pull request #26 from united-pooh/fix/fix-star-on-error-fallback
fix(runtime): avoid instantiating Star in on_error fallback
This commit is contained in:
@@ -838,7 +838,7 @@ class HandlerDispatcher:
|
|||||||
if inspect.isawaitable(result):
|
if inspect.isawaitable(result):
|
||||||
await result
|
await result
|
||||||
return
|
return
|
||||||
await Star().on_error(exc, event, ctx)
|
await Star.default_on_error(exc, event, ctx)
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["CapabilityDispatcher", "HandlerDispatcher"]
|
__all__ = ["CapabilityDispatcher", "HandlerDispatcher"]
|
||||||
|
|||||||
@@ -102,7 +102,9 @@ class Star(PluginKVStoreMixin):
|
|||||||
options=options,
|
options=options,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def on_error(self, error: Exception, event, ctx) -> None:
|
@staticmethod
|
||||||
|
async def default_on_error(error: Exception, event, ctx) -> None:
|
||||||
|
del ctx
|
||||||
if isinstance(error, AstrBotError):
|
if isinstance(error, AstrBotError):
|
||||||
lines: list[str] = []
|
lines: list[str] = []
|
||||||
if error.retryable:
|
if error.retryable:
|
||||||
@@ -122,6 +124,9 @@ class Star(PluginKVStoreMixin):
|
|||||||
await event.reply("出了点问题,请联系插件作者")
|
await event.reply("出了点问题,请联系插件作者")
|
||||||
logger.error("handler 执行失败\n{}", traceback.format_exc())
|
logger.error("handler 执行失败\n{}", traceback.format_exc())
|
||||||
|
|
||||||
|
async def on_error(self, error: Exception, event, ctx) -> None:
|
||||||
|
await Star.default_on_error(error, event, ctx)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __astrbot_is_new_star__(cls) -> bool:
|
def __astrbot_is_new_star__(cls) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user