We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug 根据 #231 这里的描述,我在其中一个命令中注册了通用错误处理器,但是在另外一个命令中,在正确执行命令后,又必定匹配到 khl.command.exception.Exceptions.Lexer.NotMatched 的错误,导致回复异常消息
khl.command.exception.Exceptions.Lexer.NotMatched
To Reproduce 最小demo为:
async def common_error_handler(cmd: command.Command, exc: Exception, msg: Message): logger.error(f"Command {cmd.name} raised an exception: {exc}") if isinstance(exc, Exceptions.Handler.ArgLenNotMatched): cm = CardTemplate.warning_card( card_title="参数长度错误", main_modules=[ Module.Section("请检查命令是否正确"), Module.Section("如果你不知道应该如何使用,请查看文档"), ], ) elif isinstance(exc, ArgParseError): cm = CardTemplate.warning_card( card_title="参数解析错误", main_modules=[ Module.Section(f"**错误**:{exc}"), Module.Section("如果你不知道应该如何使用,请查看文档"), ], ) else: cm = CardTemplate.danger_card( card_title="发生了一个未知错误", main_modules=[ Module.Section(f"发生了一个未知错误:{type(exc)} {exc}"), Module.Section("请重试。如果无法解决,请联系开发者"), ], ) await msg.reply(cm.get_card_message()) default_exc_handlers: dict[Any, TypeEHandler] = { Exception: common_error_handler, } @bot.command( name="直播", aliases=["live"], exc_handlers=common.default_exc_handlers, ) async def set_live(message: PublicMessage, cmd: str, room_id: str, notify_role: str = ""): ... @bot.command( name="帮助", aliases=["help"], ) async def help(msg: Message): ...
此时,我调用 /prefix 帮助时,会回复两个命令,一个是正常的帮助回复,一个是通用错误处理器里的错误,并得到日志:
Expected behavior 在单个命令中设置exc_handlers不会影响到其他命令
Logs/Screenshots
报错是
2024-05-04 13:38:50.882 | ERROR | wtbot.kook.commands.common:common_error_handler:12 - Command 直播 raised an exception:
Environment
Additional context Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
我看下是不是哪里没有deep copy导致重复使用了
Sorry, something went wrong.
这个问题是否有进展?大概会是哪里的问题?
No branches or pull requests
Describe the bug
根据 #231 这里的描述,我在其中一个命令中注册了通用错误处理器,但是在另外一个命令中,在正确执行命令后,又必定匹配到
khl.command.exception.Exceptions.Lexer.NotMatched
的错误,导致回复异常消息To Reproduce
最小demo为:
此时,我调用 /prefix 帮助时,会回复两个命令,一个是正常的帮助回复,一个是通用错误处理器里的错误,并得到日志:
Expected behavior
在单个命令中设置exc_handlers不会影响到其他命令
Logs/Screenshots
报错是
Environment
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: