Hi folks, How can I catch SSLHandShakeException i...
# ktor
k
Hi folks, How can I catch SSLHandShakeException in the shared code for IOS and Android?
m
You can create an expect class called PlatformSSLHandShakeException (or whatever) with no implementation, then in your iOS and Android source sets, you use an actual typealias to get the platform specific exception from Ktor. E.g: commonMain: expect class PlatformSSLHandShakeException androidMain: actual typealias PlatformSSLHandShakeException = javax.net.ssl.SSLHandShakeException iosMain: actual typealias PlatformSSLHandShakeException = io.ktor.client.engine.darwin.WhateverTheEquivalentIsOnIos
k
Thank you will try it.
m
You’re welcome. I just curiously did some research on the SSLHandShakeException equivalent on Ktor Darwin and this might not be of that much help, since it seems the Ktor Darwin engine just returns DarwinHttpRequestException ambiguously all the time. Try it out first though and do some research to see if you can find a better equivalent.
🙏🏼 1