forked from GitHub-Mirror/riotX-android
Mutualize :? part
This commit is contained in:
parent
357123743f
commit
7b5dff3dcf
@ -31,15 +31,14 @@ class ErrorFormatter @Inject constructor(val stringProvider: StringProvider) {
|
|||||||
|
|
||||||
fun toHumanReadable(throwable: Throwable?): String {
|
fun toHumanReadable(throwable: Throwable?): String {
|
||||||
return when (throwable) {
|
return when (throwable) {
|
||||||
null -> ""
|
null -> null
|
||||||
is Failure.NetworkConnection -> stringProvider.getString(R.string.error_no_network)
|
is Failure.NetworkConnection -> stringProvider.getString(R.string.error_no_network)
|
||||||
is Failure.ServerError -> {
|
is Failure.ServerError -> {
|
||||||
throwable.error.message.takeIf { it.isNotEmpty() }
|
throwable.error.message.takeIf { it.isNotEmpty() }
|
||||||
?: throwable.error.code.takeIf { it.isNotEmpty() }
|
?: throwable.error.code.takeIf { it.isNotEmpty() }
|
||||||
?: stringProvider.getString(R.string.unknown_error)
|
|
||||||
}
|
}
|
||||||
else -> throwable.localizedMessage
|
else -> throwable.localizedMessage
|
||||||
|
}
|
||||||
?: stringProvider.getString(R.string.unknown_error)
|
?: stringProvider.getString(R.string.unknown_error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user