https://kotlinlang.org logo
#android
Title
# android
w

Wouter Vegter

02/07/2019, 2:32 PM
Situation: I have a crash popping up in my crashlytics, where a JobCancellationException is thrown, that has no usable stackstrace. Idea: Now I like to write a specific catch mechanism via Thread.setUncaughtExceptionHandler, so that I can inspect different properties of this JobCancellationException, and add it to the crashlytics crash report. I have tried quite some variations to force a JobCancellationException, but none of them have succeeded. Question: Does anyone know a small android-kotlin codesample that will for sure throw a JobCancellationException? Thanks for reading this!
a

ansman

02/07/2019, 4:25 PM
CancellationException
should be ignored, they are a part of the internals of coroutines and shouldn’t be logged
This will cause an exception:
Copy code
runBlocking {
    withTimeoutOrNull(200) {
        // Will throw a CancellationException after
        // waiting for 200ms
        delay(400)
    }
}
w

Wouter Vegter

02/07/2019, 4:50 PM
thank you for helping me!
6 Views