Skip to content

Commit

Permalink
Handle no internet connection error for sectors request
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed Jan 2, 2025
1 parent 18b2304 commit ec09e01
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.net.UnknownHostException

class MarketFiltersViewModel(val service: MarketFiltersService) :
Expand Down Expand Up @@ -72,9 +71,11 @@ class MarketFiltersViewModel(val service: MarketFiltersService) :
}

private fun loadSectors() {
viewModelScope.launch(Dispatchers.IO) {
withContext(Dispatchers.Default) {
viewModelScope.launch(Dispatchers.Default) {
try {
sectors = service.getSectors()
} catch (e: Throwable) {
//not handled
}
}
}
Expand Down

0 comments on commit ec09e01

Please sign in to comment.