Improve error message of downloadLongMessage&ForwardMessage

This commit is contained in:
Karlatemp 2021-11-06 23:24:09 +08:00
parent 69931538f5
commit 0403de2b39
No known key found for this signature in database
GPG Key ID: 21FBDDF664FF06F8

View File

@ -885,13 +885,21 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
)
override suspend fun downloadLongMessage(bot: Bot, resourceId: String): MessageChain {
return downloadMultiMsgTransmit(bot, resourceId, ResourceKind.LONG_MESSAGE).msg
.toMessageChainNoSource(bot, 0, MessageSourceKind.GROUP)
.refineDeep(bot)
try {
return downloadMultiMsgTransmit(bot, resourceId, ResourceKind.LONG_MESSAGE).msg
.toMessageChainNoSource(bot, 0, MessageSourceKind.GROUP)
.refineDeep(bot)
} catch (error: Throwable) {
throw IllegalStateException("Failed to download long message `$resourceId`", error)
}
}
override suspend fun downloadForwardMessage(bot: Bot, resourceId: String): List<ForwardMessage.Node> {
return downloadMultiMsgTransmit(bot, resourceId, ResourceKind.FORWARD_MESSAGE).toForwardMessageNodes(bot)
try {
return downloadMultiMsgTransmit(bot, resourceId, ResourceKind.FORWARD_MESSAGE).toForwardMessageNodes(bot)
} catch (error: Throwable) {
throw IllegalStateException("Failed to download forward message `$resourceId`", error)
}
}
internal open suspend fun MsgTransmit.PbMultiMsgNew.toForwardMessageNodes(