【发布时间】:2022-12-25 21:32:51
【问题描述】:
我试图以这种方式捕获应用程序错误:
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
try {
MyApp()
}
catch (t: Throwable) {
Text(t.message ?: "Error", fontSize = 24.sp)
Text(t.stackTraceToString(), fontFamily = FontFamily.Monospace)
}
}
}
}
但它不编译:
可组合函数调用不支持 Try catch。
什么鬼?
我还应该使用什么?
【问题讨论】:
标签: kotlin android-jetpack-compose