mirror of
https://github.com/mamoe/mirai.git
synced 2024-12-27 17:10:15 +08:00
[core] CoroutineOnDemandValueScope: fix exception message when emit/receive while producer is already finished
This commit is contained in:
parent
a1d8d744d0
commit
578d1a9d48
@ -154,16 +154,21 @@ internal sealed interface ProducerState<T, V> {
|
|||||||
|
|
||||||
fun createAlreadyFinishedException(cause: Throwable?): IllegalProducerStateException {
|
fun createAlreadyFinishedException(cause: Throwable?): IllegalProducerStateException {
|
||||||
val exception = exception
|
val exception = exception
|
||||||
|
val causeMessage = if (cause == null) {
|
||||||
|
""
|
||||||
|
} else {
|
||||||
|
", but attempting to finish with the cause $cause"
|
||||||
|
}
|
||||||
return if (exception == null) {
|
return if (exception == null) {
|
||||||
IllegalProducerStateException(
|
IllegalProducerStateException(
|
||||||
this,
|
this,
|
||||||
"Producer has already finished normally, but attempting to finish with the cause $cause. Previous state was: $previousState",
|
"Producer has already finished normally$causeMessage. Previous state was: $previousState",
|
||||||
cause = cause
|
cause = cause
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
IllegalProducerStateException(
|
IllegalProducerStateException(
|
||||||
this,
|
this,
|
||||||
"Producer has already finished with the suppressed exception, but attempting to finish with the cause $cause. Previous state was: $previousState",
|
"Producer has already finished with the suppressed exception$causeMessage. Previous state was: $previousState",
|
||||||
cause = cause
|
cause = cause
|
||||||
).apply {
|
).apply {
|
||||||
addSuppressed(exception)
|
addSuppressed(exception)
|
||||||
|
Loading…
Reference in New Issue
Block a user