Can I somehow get away from these exceptions? I'm ...
# ktor
j
Can I somehow get away from these exceptions? I'm handling these myself
a
You can disable default response validation by setting
expectSuccess
property to `false`https://ktor.io/docs/response-validation.html#default
j
thanks 😄
But then this doesn't call?:
Copy code
HttpResponseValidator {
            handleResponseException {
                val clientException = it as? ClientRequestException ?: return@handleResponseException
                errorHandler.handle(clientException)
            }
        }
in the http client
a
What do you mean?
Could you please describe your problem?
j
when I set the expectSuccess to false, the response validator thing doesnt get called. Thats my full builder:
Copy code
val http = HttpClient {
        config.httpClientConfig(this)
        defaultRequest {
            header("Authorization", "Bot ${config.token}")
            header("User-Agent", "<http://Discord.KM|Discord.KM> (\$<https://github.com/jan-tennert/Discord.KM>, $0.3)")
        }

        HttpResponseValidator {
            handleResponseException {
                val clientException = it as? ClientRequestException ?: return@handleResponseException
                errorHandler.handle(clientException)
            }
        }

        expectSuccess = false
    }
a
It gets called if any exceptions are thrown. You can use
validateResponse
inside
HttpResponseValidator
to validate a response.
So you can disable default response validation and do it by yourself.