Kotlin-Coroutines-Android-Examples icon indicating copy to clipboard operation
Kotlin-Coroutines-Android-Examples copied to clipboard

Handle network exception in data layer

Open ArezooNazer opened this issue 4 years ago • 1 comments

In this project, the network exceptions are handled in ViewModel and it's not a good approach. How can we handle network errors such as 404, 500, etc inside of the repository?

ArezooNazer avatar Mar 07 '21 18:03 ArezooNazer

@ArezooNazer You can wrap the List<ApiUser> with Response<List<ApiUser>>

Response is from Retrofit.

shipsywor avatar Jul 14 '21 15:07 shipsywor