Martin Nordholts
01/14/2020, 1:01 PM01-14 11:40:10.990 4508 4508 E AndroidRuntime: FATAL EXCEPTION: main @coroutine#4
01-14 11:40:10.990 4508 4508 E AndroidRuntime: Process: com.readly.client, PID: 4508
I am running with
System.setProperty(kotlinx.coroutines.DebugKt.DEBUG_PROPERTY_NAME, kotlinx.coroutines.DebugKt.DEBUG_PROPERTY_VALUE_ON)
but still get the above silent fail.
What is the best way to find what coroutine this is? (Without using “brute force”)tseisel
01/14/2020, 1:15 PMGlobalScope
, those are the most susceptible to fail silently.Martin Nordholts
01/14/2020, 1:16 PMBegin by checking all coroutines that are launched withThanks for the tip which certainly would work, but I would like to find a way that does not use brute force, because that doesn’t scale well (e.g. to a codebase that has a ton of coroutines), those are the most susceptible to fail silently.GlobalScope
tseisel
01/14/2020, 1:22 PMMartin Nordholts
01/14/2020, 1:37 PMtseisel
01/14/2020, 2:20 PMCoroutineExceptionHandler
that will perform the necessary logging (printing a stacktrace) : https://kotlinlang.org/docs/reference/coroutines/exception-handling.html#coroutineexceptionhandlerMartin Nordholts
01/14/2020, 2:33 PMThread.setDefaultUncaughtExceptionHandler { t: Thread, e: Throwable ->
Log.e("foo", "bar", e)
}
and now I can get a stack trace 👍