Why does the Ktor client not allow me to get the r...
# ktor
o
Why does the Ktor client not allow me to get the response body of a non-200 response? 😕
j
I do this:
Copy code
try {
        call()
    } catch (e: ResponseException) {
        val status = e.response.status
        val body = e.response.readText()
call() is a function reference to a normal ktor call
o
Hmm, I think I already tried that. Besides that, is it by design that the exception of a request doesnt get thrown until you call readText()?
r
There is a way to disable exceptions for non-2xx codes if that's what you are aiming for: https://ktor.io/clients/http-client/features/response-validation.html#expect-success
2