reactormonk
07/12/2022, 10:00 AMBig Chungus
07/12/2022, 12:32 PMreactormonk
07/12/2022, 12:34 PMBig Chungus
07/12/2022, 12:34 PMBig Chungus
07/12/2022, 12:35 PMreactormonk
07/12/2022, 12:35 PMBig Chungus
07/12/2022, 12:36 PMBig Chungus
07/12/2022, 12:37 PMreactormonk
07/12/2022, 12:45 PMsuspend fun a() { suspendCoroutine { block -> block.resumeWithException(IOException()) } }
suspend fun b() { try { a() } catch (e: IOException) { println(e) }
Won't catch the exception?Big Chungus
07/12/2022, 12:50 PMreactormonk
07/12/2022, 12:51 PMreactormonk
07/12/2022, 12:52 PMreactormonk
07/12/2022, 12:55 PMreactormonk
07/12/2022, 12:55 PMBig Chungus
07/12/2022, 12:55 PMBig Chungus
07/12/2022, 12:56 PMBig Chungus
07/12/2022, 12:56 PMreactormonk
07/12/2022, 1:00 PMBig Chungus
07/12/2022, 1:01 PMreactormonk
07/12/2022, 1:09 PMcoroutineScope { try ... }
or b) start using suspend fun a(): Result()
and manually pass things along?Nick Allen
07/12/2022, 4:03 PMtry {
launch { a() }
} catch (e: IOException) {}
would not catch anything because the exception is in a different coroutine than the one catching so it's not part of the same conceptual call stack.reactormonk
07/12/2022, 4:04 PMBig Chungus
07/12/2022, 4:13 PM