CoroutineExceptionHandler “swallows” exceptions, but handleException() function isn’t called

Crap, I’ve just wasted an entire hour due to extra pair of curly braces.

I wrote this:

    val exceptionHandler = CoroutineExceptionHandler { _, throwable -> {
        println("Caught exception")
    }}

But the correct way of using that is this:

    val exceptionHandler = CoroutineExceptionHandler { _, throwable ->
        println("Caught exception")
    }

Then it works.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top