Swift Concurrency: Feedback Wanted!

Concurrency works really great, amazing work thank you!!

My feedback so far is regarding error handling. Still feels a little archaic and hoping strongly-typed errors be revisited in light of Concurrency. This was discussed in various threads over the years, but a throw to a general purpose Error is really difficult for the callers to handle errors without knowing the implementation details and feels like a gap. This could finally rid the need of the well served Result type once and for all.

Going from this:

do {
    try await performWork()
} catch let error as MyError {
    switch error { // Exhaust all error cases
        case .invalidUser: ...
        case .expiredToken: ...
        case .etc: ...
    }
} catch {
    // Will never reach here but need to satisfy compiler
}

To this:

do {
    try await performWork()
} catch .invalidUser {
    ...
} catch .expiredToken {
    ...
} catch .etc {
    ...
} 

Also another completely different feedback I have is I noticed crashes while mixing GCD. I understand this is not the intended use case, but I think this will be unavoidable when async tasks performs work using dependencies and SDKs where we have no control or knowledge of the underlying implementation. I'm wondering if changing the GCD under the hood to switch between legacy and async/await implementation based on the caller would prevent these crashes?

4 Likes