Exception: java.lang.ClassCastException: kotlin.Result$Failure cannot be cast to retrofit2.Response
at com.example.Setup$loadConfig$1.invokeSuspend(Setup.kt:385)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:285)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
at kotlinx.coroutines.scheduling.CoroutineScheduler.access$getSchedulerName$p(CoroutineScheduler.kt:60)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742)
Same here. Have number of similar stacktraces from every place I use coroutines in but it is impossible to find out what the root cause was. I can only guess it might be a network issue.
Is there a way to handle exceptions from Retrofit? We often get these ClassCastExceptions in the
await()
call.