It would be good to use this: https://stackoverflow.com/questions/32758811/catching-nsexception-in-swift everywhere.
Having this everywhere will make code looks verbose. We could use it in potential dangerous places but wrapping each objc function/method is too much.
That would be verbose, yes. The issue is that almost anything can potentially throw ObjC exception. MailCore - ObjC. Gmail API - ObjC. Texture - ObjC.
Do we necessarily have to catch it exactly on the first boundary from ObjC to Swift? Or could it be later? Best would be if we only had to do it once per Task - then it's not too verbose.
fun handle() {
Task {
do {
try ObjC.catch {
try await thisCanThrowSwift()
try await thisCallsMethodThatCallsMethodThatCanThrowObjc()
thisCanTrhowObjC()
someOtherCode()
}
} catch {
handle(error)
}
}
}
Originally posted by @tomholub in #1076 (comment)
That would be verbose, yes. The issue is that almost anything can potentially throw ObjC exception. MailCore - ObjC. Gmail API - ObjC. Texture - ObjC.
Do we necessarily have to catch it exactly on the first boundary from ObjC to Swift? Or could it be later? Best would be if we only had to do it once per
Task- then it's not too verbose.Originally posted by @tomholub in #1076 (comment)