Nikky
10/30/2019, 10:17 AMelizarov
10/30/2019, 10:25 AMCoroutineExceptionHandler to the GlobalScope or just catch your exceptions in the coroutines you launch.elizarov
10/30/2019, 10:26 AMNikky
10/30/2019, 10:32 AMNikky
10/30/2019, 10:34 AMglobal exception handler
does that mean it is not possible for kotlin-js ?Fudge
10/30/2019, 11:31 AMfun errorer() {
GlobalScope.launch {
error("asdf")
}
}
fun main() {
errorer()
}Fudge
10/30/2019, 11:32 AMsuspend fun errorer() = coroutineScope {
launch {
error("asdf")
}
}
suspend fun main() {
errorer()
}Dico
10/30/2019, 11:35 AMFudge
10/30/2019, 11:35 AMFudge
10/30/2019, 11:38 AMsuspend fun errorer() = coroutineScope {
launch {
error("asdf")
}
}
suspend fun main() {
try {
errorer()
} catch (e: Exception) {
println("Caught")
}
Thread.sleep(1000)
}
If you do this the exception won't be caught
fun errorer() {
GlobalScope.launch {
error("asdf")
}
}
fun main() {
try {
errorer()
} catch (e: Exception) {
println("Caught")
}
Thread.sleep(1000)
}Fudge
10/30/2019, 11:40 AMNikky
10/30/2019, 12:14 PMelizarov
10/30/2019, 12:50 PMval myScope = GlobalScope + CoroutineExceptionHandler { ... }
then use myScope.launch { ... }elizarov
10/30/2019, 12:50 PMGlobalScope usage across your project with myScope.elizarov
10/30/2019, 12:53 PMconsole.error(exception). So it should not be “lost” either.