Skip to content

Commit

Permalink
Fix crash when a request of TrackMaps of user are null
Browse files Browse the repository at this point in the history
  • Loading branch information
davidasensio committed Sep 4, 2020
1 parent 40b2ee4 commit 0de0ebf
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -18,7 +18,11 @@ class ServerDataSource(private val service: TrackMapService) : RemoteDataSource
}

override suspend fun getUserTrackMaps(userId: String): Map<String, TrackMap> {
return service.getUserTrackMaps(userId)
return try {
service.getUserTrackMaps(userId)
} catch (e: Exception) {
HashMap() // Return an empty HashMap when a request returns null
}
}

override suspend fun saveTrackMap(userId: String, trackMapId: String, trackMap: TrackMap) {
Expand Down

0 comments on commit 0de0ebf

Please sign in to comment.