Uncaught exceptions in Dispatchers.Default


#1

On Android, is there a way for exceptions thrown by a suspending block called by withContext(Dispatchers.Default) not to end up in the app’s default uncaught exception handler?

For instance, the following code crashes the app:

suspend fun foo() {
    try {
        withContext(Dispatchers.Default) {
            throw Error()
        }
    } catch (t: Throwable) {
        // this is reached, but the the exception also ends up in the
        // app's default uncaught exception handler
    }
}