Consolidate exception message formatting

Closes #9408
This commit is contained in:
arkon
2023-04-27 22:45:30 -04:00
parent 41c89eb61d
commit c9805b8612
3 changed files with 24 additions and 17 deletions

View File

@@ -18,6 +18,7 @@ import eu.kanade.domain.manga.model.toSManga
import eu.kanade.domain.ui.UiPreferences
import eu.kanade.presentation.manga.DownloadAction
import eu.kanade.presentation.manga.components.ChapterDownloadAction
import eu.kanade.presentation.util.formattedMessage
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.download.DownloadCache
import eu.kanade.tachiyomi.data.download.DownloadManager
@@ -227,7 +228,7 @@ class MangaInfoScreenModel(
logcat(LogPriority.ERROR, e)
coroutineScope.launch {
snackbarHostState.showSnackbar(message = e.snackbarMessage)
snackbarHostState.showSnackbar(message = with(context) { e.formattedMessage })
}
}
}
@@ -517,7 +518,7 @@ class MangaInfoScreenModel(
context.getString(R.string.no_chapters_error)
} else {
logcat(LogPriority.ERROR, e)
e.snackbarMessage
with(context) { e.formattedMessage }
}
coroutineScope.launch {
@@ -1000,14 +1001,6 @@ class MangaInfoScreenModel(
}
}
}
private val Throwable.snackbarMessage: String
get() = when (val className = this::class.simpleName) {
null -> message ?: ""
"SourceNotInstalledException" -> context.getString(R.string.loader_not_implemented_error)
"Exception", "HttpException", "IOException" -> message ?: className
else -> "$className: $message"
}
}
sealed class MangaScreenState {