Skip to content

Commit

Permalink
Fix crash when Spotify is not available in user's country #5
Browse files Browse the repository at this point in the history
(show no internet/server down dialog)
  • Loading branch information
Lambada10 committed Jun 29, 2023
1 parent 2659e78 commit 8f6b274
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/src/main/java/pl/lambada/songsync/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import pl.lambada.songsync.ui.components.BottomBar
import pl.lambada.songsync.ui.components.TopBar
import pl.lambada.songsync.ui.components.dialogs.NoInternetDialog
import pl.lambada.songsync.ui.theme.SongSyncTheme
import java.io.FileNotFoundException
import java.net.UnknownHostException

/**
Expand Down Expand Up @@ -57,8 +58,11 @@ class MainActivity : ComponentActivity() {
launch(Dispatchers.IO) {
try {
viewModel.refreshToken()
} catch (e: UnknownHostException) {
internetConnection = false
} catch (e: Exception) {
if (e is UnknownHostException || e is FileNotFoundException)
internetConnection = false
else
throw e
}
}
}
Expand Down

0 comments on commit 8f6b274

Please sign in to comment.