supervisorScope

suspend fun <R> supervisorScope(
    block: suspend CoroutineScope.() -> R
): R
(source)

Creates new CoroutineScope with SupervisorJob and calls the specified suspend block with this scope. The provided scope inherits its coroutineContext from the outer scope, but overrides context’s Job with SupervisorJob.

A failure of a child does not cause this scope to fail and does not affect its other children, so a custom policy for handling failures of its children can be implemented. See SupervisorJob for details. A failure of the scope itself (exception thrown in the block or cancellation) fails the scope with all its children, but does not cancel parent job.