Philipp Bykow
01/25/2022, 2:36 PMFunction doesn't have or inherit @Throws annotation and thus exception isn't propagated from Kotlin to Objective-C/Swift as NSError. and crashes the App. In the class init we call something like this
coroutineScope.launch {
test()
}
The test function is as followed:
@Throws(Exception::class)
private suspend fun test() {
...
}kpgalligan
01/25/2022, 5:04 PMcoroutineScope.launch from Swift is failing. It’s probably wrapping and throwing whatever test() throws.kpgalligan
01/25/2022, 5:05 PMcoroutineScope.launch call with try/catch, print that stack trace, then rethrow.kpgalligan
01/25/2022, 5:06 PM@Throws if you want to bubble errors up to Swift. However, you’ll need to use explicit try calls from Swift. Exceptions in that context are very different. We basically don’t use @Throwskpgalligan
01/25/2022, 5:07 PMPhilipp Bykow
01/26/2022, 12:11 PM