onClosed

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

Performs the given action on the encapsulated Throwable exception if this instance represents failure due to channel being closed. 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.