diff --git a/core/datastore/src/main/kotlin/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSource.kt b/core/datastore/src/main/kotlin/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSource.kt index 5cc237ff7c..ba45606dfb 100644 --- a/core/datastore/src/main/kotlin/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSource.kt +++ b/core/datastore/src/main/kotlin/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSource.kt @@ -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,