Straying From the Happy Path: Taking Control of Errors in Swift
summary
Covers concrete Swift patterns: using Result (not yet in stdlib), AlamoFire response quirks, and XCTAssertThrowsError to verify thrown errors; shows how to replace fatalError in tests by swapping a never-returning closure so code that would crash gets tested and the project reaches 100% test coverage for those lines. Demonstrates a generic dequeue that throws ProgrammerError for UITableView cells, use of assertionFailure/precondition for debug vs release, logging helpers, and coordinating user-facing vs developer-facing errors.
AI-written summary · about
chapters (20)
- 0:00Introduction
- 1:05Error handling problems
- 2:28Swift Result type
- 4:15Handling errors effectively
- 6:11Throwing errors in Swift
- 7:14Advanced error handling
- 8:41Fatal error vs testing
- 10:27Testing fatalError
- 15:07When to use fatalError
- 17:13Assertion failure vs fatalError
- 19:22Programmer error handling
- 21:33Testing programmer errors
- 22:37Logging errors effectively
- 24:08Typed throws in Swift
- 25:54Q&A: Handling errors
- 26:59Q&A: Error layers
- 29:49Q&A: Localized errors
- 31:16Q&A: Legacy outlet issues
- 33:49Improved table view handling
- 36:38Closing remarks
related talks
34mStraying From the Happy Path: Taking Control of Errors in Swift
23mLessons in Swift Error Handling and Resilience
40mLeveraging Swift’s Type System
50mWriting Swift code with great testability
30mLeveraging Swift's Type System
55mEmerging Best Practices
20mHow Not to Write Swift
52mType-Driven Design with Swift
