mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-21 12:11:50 +01:00
Add more user-friendly network-related exception messages
This commit is contained in:
parent
f32243899d
commit
6922792ad1
@ -4,16 +4,26 @@ import android.content.Context
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.network.HttpException
|
||||
import eu.kanade.tachiyomi.source.online.LicensedMangaChaptersException
|
||||
import eu.kanade.tachiyomi.util.system.isOnline
|
||||
import tachiyomi.data.source.NoResultsException
|
||||
import tachiyomi.domain.source.model.SourceNotInstalledException
|
||||
import java.net.UnknownHostException
|
||||
|
||||
context(Context)
|
||||
val Throwable.formattedMessage: String
|
||||
get() {
|
||||
when (this) {
|
||||
is HttpException -> return getString(R.string.exception_http, code)
|
||||
is UnknownHostException -> {
|
||||
return if (!isOnline()) {
|
||||
getString(R.string.exception_offline)
|
||||
} else {
|
||||
getString(R.string.exception_unknown_host, message)
|
||||
}
|
||||
}
|
||||
|
||||
is NoResultsException -> return getString(R.string.no_results_found)
|
||||
is SourceNotInstalledException -> return getString(R.string.loader_not_implemented_error)
|
||||
is HttpException -> return "$message: ${getString(R.string.http_error_hint)}"
|
||||
is LicensedMangaChaptersException -> return getString(R.string.licensed_manga_chapters_error)
|
||||
}
|
||||
return when (val className = this::class.simpleName) {
|
||||
|
@ -606,8 +606,6 @@
|
||||
<!-- missing prompt after Compose rewrite #7901 -->
|
||||
<string name="no_more_results">No more results</string>
|
||||
<string name="no_results_found">No results found</string>
|
||||
<!-- Do not translate "WebView" -->
|
||||
<string name="http_error_hint">Check website in WebView</string>
|
||||
<string name="licensed_manga_chapters_error">Licensed - No chapters to show</string>
|
||||
<string name="local_source">Local source</string>
|
||||
<string name="other_source">Other</string>
|
||||
@ -947,4 +945,10 @@
|
||||
<string name="appwidget_updates_description">See your recently updated library entries</string>
|
||||
<string name="appwidget_unavailable_locked">Widget not available when app lock is enabled</string>
|
||||
<string name="remove_manga">You are about to remove \"%s\" from your library</string>
|
||||
|
||||
<!-- Common exceptions -->
|
||||
<!-- Do not translate "WebView" -->
|
||||
<string name="exception_http">HTTP %d, check website in WebView</string>
|
||||
<string name="exception_offline">No Internet connection</string>
|
||||
<string name="exception_unknown_host">Couldn\'t reach %s</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user