toUiText
The text a screen shows for this failure.
Failures the user can act on get their own text: being offline, a timeout, a busy server, full storage. Every other failure, including a bug, gets fallback, which a screen sets to what it was doing ("Could not load the FAQ"), because the cause would mean nothing to the user and is already reported to Crashlytics.
A screen with failures of its own handles them first and passes the rest here:
private fun Throwable.toFaqText(): UiText = when (this) {
is FaqUnavailableException -> UiText.StringResource(R.string.faq_unavailable)
else -> toUiText(fallback = UiText.StringResource(R.string.faq_load_failed))
}Content copied to clipboard