考虑这样的代码:
\ncoroutineScope {\n try {\n supervisorScope { launch { error("") } }\n } catch (t: Throwable) {\n println("logs and stuff")\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n运行此代码,我希望logs and stuff在输出中看到,但它会将异常一直传播到原始范围,除非已CoroutineExceptionHandler安装,否则它将失败。
问题是:这是设计使然,还是一个错误(如果是这样,\xe2\x80\x94 将打开一个问题)?
\nPS 切换到内部coroutineScope“修复”问题
coroutineScope {\n try {\n coroutineScope { launch { error("") } }\n } catch (t: Throwable) {\n println("now you\'ll see it")\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n