• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package kotlinx.coroutines.test.internal
2 
3 import kotlinx.coroutines.*
4 
5 /**
6  * A variant of [SupervisorJob] that additionally notifies about child failures via a callback.
7  */
8 @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
9 internal class ReportingSupervisorJob(
10     parent: Job? = null,
11     val onChildCancellation: (Throwable) -> Unit
12 ) : JobImpl(parent) {
childCancellednull13     override fun childCancelled(cause: Throwable): Boolean =
14         try {
15             onChildCancellation(cause)
16         } catch (e: Throwable) {
17             cause.addSuppressed(e)
18             /* the coroutine context does not matter here, because we're only interested in reporting this exception
19             to the platform-specific global handler, not to a [CoroutineExceptionHandler] of any sort. */
20             handleCoroutineException(this, cause)
<lambda>null21         }.let { false }
22 }
23