Kapil Godhwani
07/03/2020, 3:31 PM{
"errorCode": 1011,
"errorMessage": "Unable to get Child information"
}
Now when I am writing a ktor client in a multi-platform module for this, I catch this in a response validator like -
HttpResponseValidator {
validateResponse {
val statusCode = it.status.value
when (statusCode) {
in 300..399 -> print(it.content.toString())
in 400..499 -> {
print(it.content.toString())
throw ClientRequestException(it)
}
in 500..599 -> print(it.content.toString())
}
}
handleResponseException {
print(it.message)
}
}
My query here is I am not able to access the response error body in either validateResponse or handleResponseException. Is there a way i can catch and parse that to get the actual error sent by server?