Skip to content

Commit

Permalink
Added more detail to the error message (#311)
Browse files Browse the repository at this point in the history
Including the name of the Turbine instance if it's not null, to clarify which instance failed.
  • Loading branch information
hishamMuneer committed Mar 10, 2024
1 parent 2b20365 commit 1126534
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/commonMain/kotlin/app/cash/turbine/Turbine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ internal class ChannelTurbine<T>(
override fun asChannel(): Channel<T> = channel

override fun add(item: T) {
if (!channel.trySend(item).isSuccess) throw IllegalStateException("Added when closed")
if (!channel.trySend(item).isSuccess) throw IllegalStateException("Attempt to add item to a closed Turbine${name?.let { " named $it" } ?: ""}.")
}

@OptIn(DelicateCoroutinesApi::class)
Expand Down

0 comments on commit 1126534

Please sign in to comment.