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

Simon Buechner

11/22/2023, 11:56 AM
Has someone used SKIE and knows how to handle exceptions in suspend functions? I can call my suspend functions and i like to use Skie but my suspend functions are throwing exceptions in the shared KMP. With native Coroutines i could handle them pretty good but i found nothing how to handle this with skie.
f

Filip Dolník

11/22/2023, 11:59 AM
Hi! Exceptions in suspend functions work exactly the same way as for other Kotlin functions exposed to Swift. So you need to add the Throws annotation to your Kotlin code and then use the
try
syntax of Swift (you can read more here: https://kotlinlang.org/docs/native-objc-interop.html#errors-and-exceptions)
s

Simon Buechner

11/23/2023, 8:51 AM
Thanks, helped a lot. i missed the Throw annotation with Exception class. @Filip Dolník 🙂