Hey. I'm using the ktor http client and i'm wonder...
# ktor
d
Hey. I'm using the ktor http client and i'm wondering if it can be configured to not throw an exception if the request fails with status 40x. I know about
Copy code
HttpClient {
  expectSuccess = false
}
but if set, the exception just changes from
ClientRequestException
to
IllegalStateException
Can the throwing of exceptions somehow be prevented completely or do i have to resort to a try/catch block?
a
i havent found a way either. catching the
ClientRequestException
and checking the response statuscode and then parsing the content to get the error body
g
We are doing this by requesting HttpResponse as the type, then we make sure the response is in 200 range and parse the content
Although we are not using content negotiation, we are doing serialization on our own