I’m creating an iOS framework using Kotlin/Native 0.5, however am not sure how you are supposed to handle exceptions properly.
Given the following class:
class TestClass() {
fun alwaysThrows() {
throw IllegalArgumentException("accountId not valid")
}
}
When alwaysThrows
is called then an exception is thrown. With interop with Swift or Obj-C you would like to be able to catch this exception however the app aborts with “Uncaught Kotlin exception: kotlin.IllegalArgumentException” regardless of what Swift or Obj-C code you wrap it with.
For example, I’ve tried @try/@catch in Obj-C, try in Swift:
@try {
[[TestClass alloc] init] alwaysThrows]
}
@catch (id exception) {
...
}
How should exceptions be handled from Swift/Obj-C interop code?