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 don't need interceptors for this problem. Wrap the retrofit API call with try/catch like this:
suspend fun getHomeUiDetails(authToken: String): Result<HomeDetailsResponse>
return try {
val response = yourRetrofitService.getHomeUiDetails(authToken)
if (response.isSuccessful) {
return Result.Success(response)
}
return Result.Error(
IOException("Error getting details ${response.code()} ${response.message()}")
)
} catch (e: Exception) {
Result.Error(IOException("Error getting details", e))
}
}