onClosed

inline fun <T> ChannelResult<T>.onClosed(action: (exception: Throwable?) -> Unit): ChannelResult<T>(source)

Performs the given action if the operation failed because the channel was closed for that operation. The result of ChannelResult.exceptionOrNull is passed to the action parameter.

It is guaranteed that if action is invoked, then the channel is either closed for send or is closed for receive depending on the failed operation.

Returns the original ChannelResult unchanged.

A shorthand for this.also { if (isClosed) action(exceptionOrNull()) }.