mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 23:47:02 +05:30
app: swallow more errors in view model
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
43c7bcced0
commit
da13725bea
1 changed files with 3 additions and 2 deletions
|
@ -11,6 +11,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
|||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
import java.net.SocketTimeoutException
|
||||
import java.net.UnknownHostException
|
||||
|
||||
class LobstersViewModel @ViewModelInject constructor(
|
||||
|
@ -22,8 +23,8 @@ class LobstersViewModel @ViewModelInject constructor(
|
|||
private val dao = database.postsDao()
|
||||
private val coroutineExceptionHandler = CoroutineExceptionHandler { _, throwable ->
|
||||
when (throwable) {
|
||||
// Swallow UHE since that happens when there is no internet and we'll just rely on our cache
|
||||
is UnknownHostException -> {}
|
||||
// Swallow known network errors that can be recovered from.
|
||||
is UnknownHostException, is SocketTimeoutException -> {}
|
||||
else -> throw throwable
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue