Hey guys, how can I please handle double type of r...
# ktor
l
Hey guys, how can I please handle double type of responses on Ktor properly? The use case is that on 200, the response has a specific JSON per API call, on for example 400 I receive a different JSON. When using the
.body<MyObject>()
call after calling
get()
, Ktor throws at me NoTransformationFoundException which is true obviously. Is there a way to make it just okay with it and for example log the exception json value somewhere instead?
a
I believe you check for the http status first before attempting to retrieve the request body. If that's the case, then shouldn't have a problem extracting the error response.
a
Can you please share your code? Do you use
HttpResponseValidator
?
l
I am not using
HttpResponseValidator
just calling
.body<MyDataClass>()
on the network call directly