Hi all, We are using kotlin with ktor server side....
# server
a
Hi all, We are using kotlin with ktor server side. and We are using
Copy code
io.ktor.client.HttpClient
To make http calls between microservices and third parties for example: When the http call succeeded the httpResponse maps automatically to my Object, but when there is error in the http call and it failed, I expect the client will throw an exception with the satatus code 40X 50X, and it's not. I need to check manually what is the status code, and decide what to do. Am I using it wrong? Do you have another client to use?
k
I'd say it is quite common behavior as getting unusual http code is not always an exceptional situation. So plenty of http clients do the same
l
you need to set the
expectSuccess
property in the client creation : https://ktor.io/docs/response-validation.html#default
image.png
a
@Kanu I understand but we want to make our lives easier and use something already done by someone and not implement it again 🙂
@Lucas Milotich thx! I'll try it
🙌 1
I managed to do it by the way! thx!
l
great!