https://kotlinlang.org logo
Title
j

Jacob

04/18/2023, 2:28 PM
I'm working with https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/receive-catching.html which returns a ChannelResult. ChannelResult can be either succesful result or a failure result. It seems like there are 2 types of failure results. • isClosed is set to true • isClosed is set to false and an exception is available from the https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-channel-result/exception-or-null.html function My question is, for this operation, is it ever possible to get a failure result with isClosed set to false? Why would that ever happen?
j

Joffrey

04/18/2023, 2:29 PM
From the KDoc of `receiveCatching`:
The result cannot be failed without being closed.
j

Jacob

04/18/2023, 2:30 PM
Ahh so that means it will never happen?
j

Joffrey

04/18/2023, 2:31 PM
Yes.
ChannelResult
is used in other APIs, but in the case of
receiveCatching
this case will never happen