-
-
Save MaxMichel2/8baeb48a1e99a637d8cbf43cf3181995 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TopicsRepositoryImpl @Inject constructor( | |
private val topicsDataSource: TopicsDataSource | |
) : TopicsRepository { | |
override suspend fun getTopics(): DataResult<List<Topic>, TopicsRepositoryError> { | |
return safeApiCall( | |
apiCall = { topicsDataSource.getTopics() }, | |
onError = { statusCode -> | |
when (statusCode) { | |
StatusCode.NoContent -> TopicsRepositoryError.NoTopics | |
else -> null | |
} | |
} | |
) | |
} | |
// Other API calls | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment