Hi folks,
How can I catch SSLHandShakeException in the shared code for IOS and Android?
m
Mofe Ejegi
10/16/2024, 10:29 AM
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
KR
10/16/2024, 10:30 AM
Thank you will try it.
m
Mofe Ejegi
10/16/2024, 10:36 AM
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.