launchCatching
fun CoroutineScope.launchCatching(onError: (Throwable) -> Unit, block: suspend CoroutineScope.() -> Unit): Job
Launches a coroutine that reports failures of block to onError instead of the scope.
Every failure except cancellation is passed to onError and the returned Job completes normally. A failure thrown by onError itself propagates to the scope.
Cancellation: a CancellationException is rethrown, never passed to onError, so cancelling the returned Job or the scope behaves like a plain launch.
Parameters
onError
receives every non-cancellation failure of block.