-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw a HttpException when the request is sucessfull but the http status are not 2XX, like Retrofit #457
Comments
Unfortunately, with version 2, this does not work - argument Any workarounds for v2? |
@Foso , any suggestions how to tackle this with v2? |
@deividasstr isn't that working?
|
@Foso thanks, this should work. I assumed that |
Also, when the return type is |
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: