One Off the Slack: Exceptions and Compose

Bradley Campbell asked:

What’s the plan regarding try/catch with compose?

The answer seems to be… we’re working on it. 😃

Specifically, Google’s Adam Powell replied with:

we’ve had some discussions around how some error recovery constructs might work at various layers; often if something goes wrong you may want to present some alternate UI at some different layer until the condition that triggered the error passes. You don’t generally want to re-run the thing that went wrong by default whenever the recomposition would normally want to.

After all, as he points out later, you can get into some nasty infinite loops, where recomposition triggers an exception, which triggers recomposition, which triggers an exception, which triggers recomposition, …

Timo Drick also had an entry in thread with a loadingStateFor() composable that offers a loading/content/error rendering mechanism for some work being done in a coroutine.

Read the original thread in the kotlinlang Slack workspace. Not a member? Join that Slack workspace here!