fun handleCoroutineException(context: CoroutineContext, exception: Throwable)

Helper function for coroutine builder implementations to handle uncaught and unexpected exceptions in coroutines, that could not be otherwise handled in a normal way through structured concurrency, saving them to a future, and cannot be rethrown. This is a last resort handler to prevent lost exceptions.

If there is CoroutineExceptionHandler in the context, then it is used. If it throws an exception during handling or is absent, all instances of CoroutineExceptionHandler found via ServiceLoader and Thread.uncaughtExceptionHandler are invoked.


common source
Link copied to clipboard