I am using Retrofit 2.6.0 with coroutines for my web service call. I am getting the API response properly with all response codes (success & error cases). My Issue is when I
you could do the following in your ViewModel to gracefully handle exceptions:
viewModelScope.launch {
kotlin.runCatching {
withContext(Dispatchers.IO){
ApiConnectionBridge.getHomeUiDetails(SharedPrefUtils.getAuthToken(context))
}
}.onSuccess {
// do something with success response
}.onFailure{
// do something on failure response
}
}