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

ptsiogas

02/15/2021, 5:25 PM
Hi there, I am using Ktor 1.5.0 combined with platform specific httpclients (OkHttp & Ios). I have setup the HttpResponseValidator although whenever I receive an http error like 401, instead of catching a custom throwable I made for this case, I am always getting a NoTransformationFoundException. Have you encountered anything similar?
r

Rustam Siniukov

02/15/2021, 5:29 PM
please check this ticket and comments https://youtrack.jetbrains.com/issue/KTOR-1703
p

ptsiogas

02/16/2021, 8:28 AM
Thanks, that helped a lot. I set
Copy code
expectSuccess = true
, then I receive a ClientRequestException. Finally I can extract the Http status like this and perform any further actions:
Copy code
val httpStatus = (error as? ResponseException)?.getHttpStatus() ?: 200

fun ResponseException.getHttpStatus(): Int {
    return response.status.value
}
I must say though that the response validator seems a really handy tool I we are awaiting for its issue to be fixed.
m

MBegemot

03/20/2021, 8:53 PM
I totally agree
amazing I got it right by setting expectSuccess=false .... But the issue is clear we send crap to de server and we want to get crap from the server ..... that's it. But we want to know ... what crap is it.
4 Views