Does anyone else have difficulty to see crash logs...
# compose-desktop
r
Does anyone else have difficulty to see crash logs when developing for and on mac? Whenever there is a runtime exception the app just crashes and disappears without anything in the logs. I’ve tried to set default uncaught exception handlers but those don’t seem to trigger
o
could you please elaborate what did you try? also did you check if JVM crashed (i.e. if files like hs_err_pidXXXX.log are present in the working dir)?
k
Did you try the Console app?
r
Yeah also doesn’t work. I think I’m found a repro that’s relatively simple
I don’t see any JVM crash logs in the working dir
One example I have is that I have this
Copy code
val state by produceState<State?>(null) {
    value = loadState()
}
loadState()
is a suspending function, it throws any exception, all my compose windows are destroyed, (JVM actually doesn’t seem to crash because the process is still alive)
And there are zero logs to indicate what the crash was
If I wrap it like this, I do see the exception in the logs
Copy code
val state by produceState<State?>(null) {
    try {
        value = loadState(service, github, playApi)
    } catch (e: Exception) {
        e.printStackTrace()
    }
}
k
Since it is a Mac app, you can always run it from the command line. Go to /Applications/<app name>/Contents/MacOS and run it from there
r
I’m not running the native distribution btw
It is just from Intellij
I see all the other logs
k
Oh. It doesn't show from Intellij? Strange. Are you using println or some sort of logging util?
r
Using println
o
exception handling in composable functions is generally may be somewhat fragile. @jim what is recommended way to catch all exceptions in such cases?
j
No, exception handling is non-existent in Compose at the moment (that is, an exception thrown across composable functions has entirely undefined results). We do intend to fix this in a future version of Compose, but it is much much harder than it would appear at first glance. The only advice at the moment is to avoid throwing exceptions from within composable functions, or catch them before they cross a composable function's scope.
With that said, I wouldn't have expected us to be swallowing exceptions. Do you have a minimal repro?