You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Using Retrofit, by default, when using suspend, when an API returns successfully (the backend actual responds), when the status code is not success (2XX) it throws a custom HttpException.
When working with Ktorfit and Ktor, when using Suspend and the direct type of the Response Body, when the server returns a 4XX with a Custom Body or Any Body at all, the Exception is ContentConvertException, this does not say nothing of what was the really cause of the error.
Describe alternatives you've considered
There are workarounds that I found that is not the best but is working so far for me that is creating a custom Converter.SuspendResponseConverter<HttpResponse, Any> that overrides the default IMPL of Ktorfit.
DevSrSouza
changed the title
Throw a HttpException when the request is sucessfull but the http status are not, like Retrofit
Throw a HttpException when the request is sucessfull but the http status are not 2XX, like Retrofit
Oct 10, 2023
Unfortunately, with version 2, this does not work - argument HttpResponse is replaced with KtorfitResult, where only success case has the notion of HttpResponse, but not failure.
Is your feature request related to a problem? Please describe.
Using Retrofit, by default, when using suspend, when an API returns successfully (the backend actual responds), when the status code is not success (2XX) it throws a custom
HttpException
.When working with Ktorfit and Ktor, when using Suspend and the direct type of the Response Body, when the server returns a 4XX with a Custom Body or Any Body at all, the Exception is
ContentConvertException
, this does not say nothing of what was the really cause of the error.Describe the solution you'd like
Creating a custom HttpException and throwing the Exception when the response is not 2XX like Retrofit does:
https://github.com/square/retrofit/blob/8abb8af6ce730b137c2a9f95c3bb5164c93e955e/retrofit-adapters/scala/src/main/java/retrofit2/adapter/scala/BodyCallAdapter.java#L47-L51
Describe alternatives you've considered
There are workarounds that I found that is not the best but is working so far for me that is creating a custom
Converter.SuspendResponseConverter<HttpResponse, Any>
that overrides the default IMPL of Ktorfit.The text was updated successfully, but these errors were encountered: