gildor / kotlin-coroutines-retrofit

Kotlin Coroutines await() extension for Retrofit Call
Apache License 2.0
847 stars 64 forks source link

`awaitResult` doesn't allow for error body deserialization #38

Closed twyatt closed 6 years ago

twyatt commented 6 years ago

One strategy for deserializing an error response is outlined in https://github.com/square/retrofit/issues/1454#issuecomment-170291423.

Unfortunately, when awaitResult returns a Result.Error, retrofit2.Response.raw() is used:

https://github.com/gildor/kotlin-coroutines-retrofit/blob/16a1641fa1122f68e8ad9646c265958f02e5690e/src/main/kotlin/ru/gildor/coroutines/retrofit/CallAwait.kt#L86

So there is no way to access the retrofit2.Response.errorBody().

twyatt commented 6 years ago

My apologies, I overlooked the fact that you pass back the retrofit2.Response in the HttpException.