Swift Sync and Async Error Handling
summary
Shows that untyped Swift throws and NSError encourage ignored or ambiguous failures and instead uses a typed Result type plus a simple Swift Future implementation that centralizes error propagation. Implements map and then (flatMap) to compose async steps, demonstrates converting between Result and throws, and reduces nested completion blocks into composable chains. Notes the naive Future works conceptually but handles only a single value stream (use ReactiveCocoa for continuous events) and warns about Futures with map and then needing explicit error-domain translation across layers.
AI-written summary · about
chapters (13)
- 0:00Introduction and motivation
- 2:39The problem with callbacks
- 5:59Limitations of NSError
- 9:36Improving error handling
- 12:10Swift error types
- 14:44Result type vs throws
- 17:12Handling error patterns
- 21:00Introduction to futures
- 23:57Implementing map
- 30:37Chaining with flat map
- 33:36Benefits of futures
- 37:16Limitations and alternatives
- 39:59Q&A and conclusion
related talks
34mModern SwiftUI Callbacks using AsyncStream
37mManaging Side Effects with Swift
43mSecond degree asyncronousity - learnings from developing iOS + IoT apps
20mSwift Concurrency's Pit of Success
33mWarning!! New technology ahead
29mLeveraging structured concurrency in your applications
52mType-Driven Design with Swift
31mThe Swift Behind SwiftUI
