阅读背景:

Android 协程 异常捕获 异常的传播特性

来源:互联网 
    @Test
    fun `test exception propagation`() = runBlocking<Unit> {
        val job = GlobalScope.launch {
            try {
                throw IndexOutOfBoundsException()
            } catch (e: Exception) {
                println("Caught: ${e}}")
            }
        }
        job.join()
        val deferred = GlobalScope.async {
            throw ArithmeticException()
        }
        try {
            deferred.await()
        } catch (e: Exception) {
            println("Caught: ${e}}")
        }

        delay(1000)

    }    @Test
    fun `test exception propagatio



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: