Hello, very stupid question, but I caught my self ...
# touchlab-tools
d
Hello, very stupid question, but I caught my self that I don’t understand why we must write it in that way. Could you help me to figure out.
Copy code
@available(iOS 13, macOS 10.15, watchOS 6, tvOS 13, *)
  func getSites() async throws -> shared.Result<Foundation.NSArray> {
    return try await SwiftCoroutineDispatcher.dispatch {
      shared.__SkieSuspendWrappersKt.Skie_Suspend__47__getSites(dispatchReceiver: self, suspendHandler: $0)
    }
  }
I have as suspend function in Kotlin that just returns Result<List> does not return any errors, but function generated by skie states
async throws
, does it assume that func might return
CancellationException
and that is why I have to write it in that way?
Copy code
let result = try? await usecase.downloadSites(dataRef: dataRef, fields: fields)
Ty in advance!
t
Hi, yes that’s correct. Any suspend function can get cancelled and throw a CancellationException and we have to propagate it to Swift. With Swift 6.0, we’ll implement typed throws to highlight that
We were considering an annotation that would mark a suspend function “@UnsafeCancellation” or something and it’d mean there’s no “throws” on Swift side and instead you’re expected to handle cancellation directly in Kotlin and return a value when cancelled. But since that’s nontrivial, we haven’t implemented it yet
2
d
Oh, cool, thank you for clarification and quick response