Skip to content
New issue

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

fix: unwarp InvocationTargetException in command stack trace #2258

Merged
merged 1 commit into from
Oct 28, 2022

Conversation

cssxsh
Copy link
Contributor

@cssxsh cssxsh commented Sep 26, 2022

在指令的方法中 throw 往往会 套着一层 InvocationTargetException, 但一般不包含有用信息,还占用有效信息的空间

2022-09-26 09:39:40 E/console: java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97)
        at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Instance.call(CallerImpl.kt:113)
        at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:108)
        at kotlin.reflect.jvm.internal.KCallableImpl.callDefaultMethod$kotlin_reflection(KCallableImpl.kt:159)
        at kotlin.reflect.full.KCallables.callSuspendBy(KCallables.kt:74)
        at net.mamoe.mirai.console.internal.command.CommandReflector$findSubCommands$6$1.invokeSuspend(CommandReflector.kt:337)
        at net.mamoe.mirai.console.internal.command.CommandReflector$findSubCommands$6$1.invoke(CommandReflector.kt)
        at net.mamoe.mirai.console.internal.command.CommandReflector$findSubCommands$6$1.invoke(CommandReflector.kt)
        at net.mamoe.mirai.console.command.descriptor.CommandSignatureFromKFunctionImpl.call$suspendImpl(CommandSignature.kt:88)
        at net.mamoe.mirai.console.command.descriptor.CommandSignatureFromKFunctionImpl.call(CommandSignature.kt)
        at net.mamoe.mirai.console.internal.command.CommandManagerImplKt.executeCommandImpl(CommandManagerImpl.kt:168)
        at net.mamoe.mirai.console.command.CommandManager.executeCommand$suspendImpl(CommandManager.kt:130)
        at net.mamoe.mirai.console.command.CommandManager.executeCommand(CommandManager.kt)
        at net.mamoe.mirai.console.command.CommandManager$INSTANCE.executeCommand(CommandManager.kt)
        at net.mamoe.mirai.console.terminal.ConsoleThreadKt$startupConsoleThread$3.invokeSuspend(ConsoleThread.kt:190)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Caused by: java.lang.IllegalStateException: 词条数量不对
        at arknights-helper-2.0.0-dev-1.mirai2.jar//xyz.cssxsh.arknights.excel.GachaKt.recruit(Gacha.kt:32)
        at arknights-helper-2.0.0-dev-1.mirai2.jar//xyz.cssxsh.mirai.arknights.command.ArknightsRecruitCommand.handler(ArknightsRecruitCommand.kt:52)
        ... 25 more

@Him188 Him188 added t:enhancement 类型: 现有功能上的优化 s:console 子系统: mirai-console labels Sep 26, 2022
@Him188 Him188 added this to the 2.14.0-RC milestone Sep 26, 2022
@Him188 Him188 added the z:ready-to-merge 状态: PR 已经可以合并, 正在等待一些安排 label Sep 26, 2022
@Him188
Copy link
Member

Him188 commented Sep 26, 2022

这个会包含调用指令的 stacktrace, 实际上也是有一定必要性的, (例如插件调用)

@Him188 Him188 removed the z:ready-to-merge 状态: PR 已经可以合并, 正在等待一些安排 label Sep 26, 2022
@Him188 Him188 assigned Karlatemp and unassigned Karlatemp Sep 26, 2022
@Him188
Copy link
Member

Him188 commented Sep 26, 2022

进行修改后,... 25 more 会被显示出来并包含指令调用栈吗

@Karlatemp
Copy link
Member

... more 本来就是对重复堆栈的压缩

@Karlatemp Karlatemp added the z:ready-to-merge 状态: PR 已经可以合并, 正在等待一些安排 label Sep 26, 2022
@Him188
Copy link
Member

Him188 commented Sep 26, 2022

谢谢 kar 老师

@Him188 Him188 merged commit 03fc3a3 into mamoe:dev Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s:console 子系统: mirai-console t:enhancement 类型: 现有功能上的优化 z:ready-to-merge 状态: PR 已经可以合并, 正在等待一些安排
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants