Anton Afanasev
06/16/2021, 2:23 PMException doesn't match @Throws-specified class list and thus isn't propagated from Kotlin to Objective-C/Swift as NSError.
It is considered unexpected and unhandled instead. Program will be terminated.
As potential solution it was proposed to use expectSuccess = false
However, there are some more use-cases where my request/response might fail (for instance serialization).
I am wondering if there are any best practices about error handling on ios.
Currently I wrap my request with try catch and convert any exception I receive from ktor with CancellationException which can be understood and converted to NSError,
but not 100% sure this is correct.
try {
return httpClient.getSomething()
} catch (cancellationException: CancellationException) {
throw cancellationException
} catch (exception: Exception) {
throw CancellationException(cause = exception)
}