Flow Exception Transparency(예외 투명성)

·
Study/Kotlin
예외 투명성이라는 개념을 이해하기 위해 예시를 보자.suspend fun main() = coroutineScope { flow { try { emit(1) } catch (e: Exception) { println("Catch exception in Flow Builder") } }.collect { throw Exception("Exception in collect") }}이렇게 생긴 코드를 실행하면 과연 예외는 어떻게 처리될까? 이전까지의 내용을 봤을 때, 예외가 처리되지 않고 앱이 크래시가 될것으로 예상한다. 하지만 놀랍게도 try-catch에서 예외가 처리되어 앱 크래시가 발생하지 않는다. ..