@@ -28,6 +28,7 @@ import net.mamoe.mirai.message.data.Message
28
28
import net.mamoe.mirai.message.data.toMessageChain
29
29
import net.mamoe.mirai.utils.MiraiLogger
30
30
import net.mamoe.mirai.utils.childScope
31
+ import java.lang.reflect.InvocationTargetException
31
32
import java.util.concurrent.locks.ReentrantLock
32
33
import kotlin.coroutines.CoroutineContext
33
34
@@ -168,6 +169,12 @@ internal suspend fun executeCommandImpl(
168
169
CommandExecuteResult .Success (resolved.callee, call, resolved)
169
170
} catch (e: CommandArgumentParserException ) {
170
171
CommandExecuteResult .IllegalArgument (e, resolved.callee, call, resolved)
172
+ } catch (e: InvocationTargetException ) {
173
+ when (val target = e.cause) {
174
+ is CommandArgumentParserException -> CommandExecuteResult .IllegalArgument (target, resolved.callee, call, resolved)
175
+ null -> CommandExecuteResult .ExecutionFailed (e, resolved.callee, call, resolved)
176
+ else -> CommandExecuteResult .ExecutionFailed (target, resolved.callee, call, resolved)
177
+ }
171
178
} catch (e: Throwable ) {
172
179
CommandExecuteResult .ExecutionFailed (e, resolved.callee, call, resolved)
173
180
}
0 commit comments