There is a description in Objective-C interop: No...
# multiplatform
r
There is a description in Objective-C interop: Note that the opposite reversed translation is not implemented yet: Swift/Objective-C error-throwing methods aren't imported to Kotlin as exception-throwing. So, I want to know how can I catch the error from the Objective-C function? For example. How can I catch
NSDecimalNumberDivideByZeroException
when I invoke
NSDecimalNumber.decimalNumberByDividingBy
function? I've used
runCatching
to wrap the invocation, but it doesn't work.
👀 1
g
You cant catch them unfortunately. From the docs:
Note that the opposite reversed translation is not implemented yet: Swift/Objective-C error-throwing methods aren't imported to Kotlin as exception-throwing.
So in the case of divide by zero, just check your divisor isnt zero before calling and throw your own exception
r
OK, but this still is a flaw of kotlin multiplatform. We cannot check the errors in advance because some errors occurred in the platform-specific functions. Anyway, thanks to your response.