onCompositionError

open override fun onCompositionError(context: Context, glanceId: GlanceId, appWidgetId: Int, throwable: Throwable)(source)

Renders our own last-resort UI when the Glance composition throws, replacing Glance's default "Can't show content" layout, and logs the failure so a broken widget stops being silent.

Overriding this is the only option available: Glance's errorUiLayout constructor parameter is internal in 1.2.0-rc01, so the approach shown in the official error-handling guide does not compile from outside the library. Note that overriding this method means errorUiLayout is never read at all.

The message comes from the Crowdin-managed Compose-resources catalog via the project's blocking getString, so it stays translated even though a RemoteViews layout cannot reference Compose resources itself.