public CoroutineExceptionHandler
An optional element on the coroutine context to handle uncaught exceptions.
By default, when no handler is installed, uncaught exception are handled in the following way:
If exception is CancellationException then it is ignored (because that is the supposed mechanism to cancel the running coroutine)
Otherwise:
if there is a interface Job
in the context, then Job.cancel
is invoked;
all instances of interface CoroutineExceptionHandler
found via ServiceLoader are invoked;
and current thread's Thread.uncaughtExceptionHandler is invoked.
Modifier and Type | Interface and Description |
---|---|
static class |
CoroutineExceptionHandler.Key
Key for
interface CoroutineExceptionHandler instance in the coroutine context. |
Modifier and Type | Field and Description |
---|---|
static CoroutineExceptionHandler.Key |
Key
Key for
interface CoroutineExceptionHandler instance in the coroutine context. |
Modifier and Type | Method and Description |
---|---|
void |
handleException(NonExistentClass context,
java.lang.Throwable exception)
Handles uncaught exception in the given context. It is invoked
if coroutine has an uncaught exception. See
CoroutineExceptionHandlerKt.handleCoroutineException . |
static CoroutineExceptionHandler.Key Key
Key for interface CoroutineExceptionHandler
instance in the coroutine context.
interface CoroutineExceptionHandler
void handleException(NonExistentClass context, java.lang.Throwable exception)
Handles uncaught exception in the given context. It is invoked
if coroutine has an uncaught exception. See CoroutineExceptionHandlerKt.handleCoroutineException
.