onCancellation

protected open fun onCancellation(cause: Throwable?): Unit (source)

This function is invoked once when this coroutine is cancelled or is completed, similarly to invokeOnCompletion with onCancelling set to true.

Parameters

cause - the cause that was passed to Job.cancel function or null if coroutine was cancelled without cause or is completing normally.