mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Mutualize :? part
This commit is contained in:
parent
357123743f
commit
7b5dff3dcf
1 changed files with 3 additions and 4 deletions
|
@ -31,15 +31,14 @@ class ErrorFormatter @Inject constructor(val stringProvider: StringProvider) {
|
|||
|
||||
fun toHumanReadable(throwable: Throwable?): String {
|
||||
return when (throwable) {
|
||||
null -> ""
|
||||
null -> null
|
||||
is Failure.NetworkConnection -> stringProvider.getString(R.string.error_no_network)
|
||||
is Failure.ServerError -> {
|
||||
throwable.error.message.takeIf { it.isNotEmpty() }
|
||||
?: throwable.error.code.takeIf { it.isNotEmpty() }
|
||||
?: stringProvider.getString(R.string.unknown_error)
|
||||
?: throwable.error.code.takeIf { it.isNotEmpty() }
|
||||
}
|
||||
else -> throwable.localizedMessage
|
||||
?: stringProvider.getString(R.string.unknown_error)
|
||||
}
|
||||
?: stringProvider.getString(R.string.unknown_error)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue