addamsson
04/02/2019, 12:46 PMclass MyClass : CoroutineScope {
    override val coroutineContext = Dispatchers.Default + SupervisorJob()
    fun doSomething(): Job {
        val handler = CoroutineExceptionHandler { _, exception ->
            // ...
        }
        return launch(handler) {
            // ...
        }
    }
}launch+ SupervisorJob()CoroutineExceptionHandlerSupervisorJobA failure or cancellation of a child does not cause the supervisor job to fail and does not affect its other children,
so a supervisor can implement a custom policy for handling failures of its children:
A failure of a child job that was created using [launch][CoroutineScope.launch] can be handled via [CoroutineExceptionHandler] in the context.CoroutineExceptionHandlerSupervisorJobahulyk
04/02/2019, 3:02 PMSupervisorJobaddamsson
04/02/2019, 4:44 PMSupervisorJobaddamsson
04/02/2019, 4:44 PMaddamsson
04/02/2019, 4:44 PMhandlerlaunchaddamsson
04/02/2019, 4:45 PMhandlerMyClassaddamsson
04/02/2019, 4:45 PMaddamsson
04/02/2019, 4:47 PMSupervisorJobJobaddamsson
04/02/2019, 4:48 PMSupervisorJobDico
04/03/2019, 6:39 AMSupervisorJobJob()CoroutineExceptionHandlerSupervisorJobaddamsson
04/03/2019, 7:07 AMahulyk
04/03/2019, 7:53 AMCoroutineExceptionHandlerJobJobaddamsson
04/03/2019, 7:56 AMCoroutineContextlaunchSupervisorJobahulyk
04/03/2019, 8:14 AMThe most basic instances of [Job] are created with [launch][CoroutineScope.launch] coroutine builder or with a `Job()` factory function. By default, a failure of any of the job's children leads to an immediately failure
of its parent and cancellation of the rest of its children. This behavior can be customized using [SupervisorJob].addamsson
04/03/2019, 8:17 AMaddamsson
04/03/2019, 8:17 AM