sindrenm
04/12/2022, 10:24 AMhandleResponseException supposed to also catch `io.ktor.client.call.NoTransformationFoundException`s? Cause it just seems to fall through in my case. I can see it catching other non-HTTP exceptions such as `kotlinx.serialization.MissingFieldException`s, for instance, and of course `io.ktor.client.features.ClientRequestException`s and `io.ktor.client.features.ServerResponseException`s. I'm on Ktor v1.6.7 on Android using the CIO engine.sindrenm
04/12/2022, 10:27 AMHttpClient(CIO) {
install(Logging) {
logger = Logger.ANDROID
level = LogLevel.ALL
}
install(JsonFeature) {
serializer = KotlinxSerializer(json)
}
HttpResponseValidator {
handleResponseException {
when (it) {
// some specialized exception conversions ...
// I would want/expect NoTransformationFoundExceptions as a potential case here
is Exception -> throw ApiException.Other(it)
}
}
}
}sindrenm
04/12/2022, 10:31 AMNoTransformationFoundException by altering my JsonFeature installation:
install(JsonFeature) {
serializer = KotlinxSerializer(json)
acceptContentTypes = listOf(ContentType("application", "pdf"))
}
This is obviously not right, but I would still expect it to end up in the handleResponseException block.Aleksei Tirman [JB]
04/12/2022, 10:49 AMNoTransformationFoundException is thrown after executing the response pipeline but HttpResponseValidator’s exception handlers are called during execution of the response pipeline. So to catch it you can wrap a receive() call in try/catch .sindrenm
04/12/2022, 10:55 AMtry/catch around all network calls, so the client config seems like the right place to put it.sindrenm
04/12/2022, 10:59 AMHttpResponse in some kind of feature in the engine config.Aleksei Tirman [JB]
04/12/2022, 12:15 PMNoTransformationFoundExceptionsindrenm
04/12/2022, 12:38 PM