The first section of handleCoroutineException() looks for a CoroutineExceptionHandler in the CoroutineContext. If found, the handleException() function will be called, passing both the context and the exception:
context[CoroutineExceptionHandler]?.let {
it.handleException(context, exception)
return
}
Notice that the execution of handleCoroutineException() will be stopped after handleException() is called because of the return.