Skip to content

Commit

Permalink
Catch exception and replace with default data
Browse files Browse the repository at this point in the history
  • Loading branch information
nur-shuvo committed Nov 25, 2024
1 parent b405e5a commit 9e36bdc
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ class NiaPreferencesDataSource @Inject constructor(
}

suspend fun getChangeListVersions() = userPreferences.data
.catch { exception ->
if (exception is IOException) {
Log.e("NiaPreferences", "Error reading user preferences.", exception)
emit(UserPreferences.getDefaultInstance())
} else {
throw exception
}
}
.map {
ChangeListVersions(
topicVersion = it.topicChangeListVersion,
Expand Down

0 comments on commit 9e36bdc

Please sign in to comment.