https://kotlinlang.org logo
Title
s

streetsofboston

06/27/2019, 7:32 PM
In the kotlin playground (play.kotlinlang.org), is there a way to print out an uncaught exception from a Coroutine (when calling
launch
from a scope without a CoroutineExceptionHandler)? Update: Solved
k

karelpeeters

06/27/2019, 7:39 PM
It prints the stacktrace for me, eg
fun main() {
    error("test")
}
prints
Exception in thread "main" java.lang.IllegalStateException: test
   at FileKt.main (File.kt:2) 
   at FileKt.main (File.kt:-1)
Do you want something different?
s

streetsofboston

06/27/2019, 7:39 PM
I see nothing….
This code-snippet finishes the Coroutine with an exception and without a CoroutineExceptionHandler, the Thread’s default uncaught-exception-handler should handle it. But I can set the default-exception handler (security issue: not allowed on the playground)
k

karelpeeters

06/27/2019, 7:43 PM
Ah coroutines, I don't know about that, sorry.
s

streetsofboston

06/27/2019, 7:47 PM
Solved: I ‘accidentally’ threw a CancellationException. Thank you!
k

karelpeeters

06/27/2019, 7:47 PM
🙂