https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
s

Stephen Gazzard

04/29/2021, 7:59 PM
Those using KMM for iOS development - how have you worked with / around these errors?
Copy code
Exception 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.
Uncaught Kotlin exception: com.apollographql.apollo.ApolloNetworkException: Failed to execute GraphQL http network request
Seems a built in part of the KMM framework is if your Kotlin function doesn’t mark @Throws() with the exception, KMM crashes your app. There’s no compile time safety enforcing that only exceptions annotated in @Throws, so it is possible that an exception is missed that later ends up crashing your iOS application. This is undesired behaviour, as if we miss documenting an exception, it can crash in the wild. In iOS, we typically just show an error message when an unexpected error arises. Is there a way to ensure that Kotlin never crashes us in this case?
m

mbonnin

04/29/2021, 11:06 PM
In that specific case though, you should probably catch that exception as it can happen in normal operation so it's not really a programming error
s

Stephen Gazzard

04/30/2021, 2:37 PM
This looks promising, thanks for the direction!
👍 1
72 Views