Is it possible to catch exceptions thrown by Swift...
# kotlin-native
k
Is it possible to catch exceptions thrown by Swift/Objective-C code? I’m integrating a library whose methods are throwing various exceptions (
NSException
) and I would like to catch and handle them, is it possible? I can see that the documentation mentions that it’s not yet possible, but maybe some work has been done in this topic? Is there any issue I can star and follow?
Note that the opposite reversed translation is not implemented yet: Swift/Objective-C error-throwing methods aren’t imported to Kotlin as exception-throwing.
s
An actual NSException is an unrecoverable error. The most you should do with it is log it out somewhere before terminating. They're not like Kotlin/Java exceptions in that way. Recoverable errors are typically passed back in an error pointer that is passed into a method that can fail.