In the light of <https://github.com/square/retrofi...
# coroutines
p
In the light of https://github.com/square/retrofit/pull/2886 how to parse error bodies efficiently? Direct implementation
Copy code
try {
  val result = retrofitService.getEndpoint()
  // ..
} catch (e: HttpException) {
  val errorBody = e.response().errorBody()
  withContext(Dispatchers.IO) {
    errorBody!!.string() // Will read bytes from network
  }
}
Seems to have jumping from okhttp thread pool -> to UI thread -> to IO thread pool 🤔 Ideally I want to stay and parse errorBody on the same thread as connection was open and http200 body is being parsed 😄 But more importantly to correctly propagate the close(stream consumed) and cancel events.