https://kotlinlang.org logo
#ktor
Title
# ktor
h

hellman

01/27/2021, 11:59 AM
Hey! Is the only way to get a HttpResponse from a call to set expectSuccess to false?
r

Rustam Siniukov

01/27/2021, 12:36 PM
Hi, there are 3 options • set
expectSuccess = false
on client level • set
expectSuccess = false
on request level
Copy code
val response = client.get<HttpResponse>(...) { expectSuccess = false }
• catch
ResponseException
and read response from it
Copy code
val response = try {
  client.get(...)
} catch (cause: ResponseException) {
  cause.response
}
👍 2
2 Views