feat: 统一插件错误处理机制#1
Draft
QingFeng-awa wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
v0 版本为每个业务逻辑方法添加了通用兜底处理机制:
这些方法高度雷同,仅是日志输出有微小差异,若在日后要全部更改并不容易,可若不处理直接由 AstrBot 返回错误信息用户侧收到的结果将相当难看,与插件设计调性不符。
此外插件也利用了 AstrBot 的指令组与带参指令功能而非自己再造轮子,然而 AstrBot 返回的通用错误信息也实在不符合插件审美。
此 PR:
@filter.on_plugin_error()Hook 大幅简化错误处理机制,同时支持占位符替换某些内容。但目前,此 PR 存在以下问题:
@filter.on_plugin_error()Hook 不支持yield event.plain_result()。AstrBot 官方文档要求通过await event.send(),但该方法不会经过装饰管道,使得 AstrBot 的回复时 @ 发送人、回复时引用发送人消息等功能无法工作,这与插件设计风格背道而驰。已提出 [Feature] 为event.send()增加可选的消息装饰开关 AstrBotDevs/AstrBot#9038 作为框架侧的缓解方法。