1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-04-25 13:03:35 +08:00

sendAndExpect: complete the result of the listener with last exception only if it has not yet completed. Maybe fix .

This commit is contained in:
Him188 2022-05-06 15:51:10 +01:00
parent 008398bd84
commit b16b3a58ac

View File

@ -108,7 +108,11 @@ internal abstract class NetworkHandlerSupport(
throwLast()
} finally {
packetListeners.remove(listener)
listener.result.completeExceptionally(getLast() ?: IllegalStateException("No response"))
if (listener.result.isActive) {
listener.result.completeExceptionally(
getLast() ?: IllegalStateException("Internal error: sendAndExpect failed without an exception.")
)
}
}
}
}