let's say I am using HttpClient w/ serialization, ...
# ktor
k
let's say I am using HttpClient w/ serialization, and I want to handle the case of invalid JSON by getting the response text. is that possible, or do I need to receive the response as text and deserialize manually?
d
Just catch
JsonProcessingException
assuming you're using jackson
k
i am using kotlinx.serialization
d
then catch the corresponding error for json deserialization - they are not caught by ktor when calling
receive<T>()
Well, they are caught by some early phase and printed to the console
k
yes, that's quite easy, but how do I get the response text?
d
with jackson the error has the full response available I think. Perhaps kotlinx.serialization has some info about it as well? What do you want to do with it?
k
the exception has a character position and what the specific error was, but it does not include the json text
I want to rethrow including the json text