0002: Error Handling Builds on Interfaces
Date: 2026-06-14 Status: Accepted
Context
The learner has completed Lesson 0001 (Go interfaces — implicit satisfaction). The next step is error handling, which is a direct application of interfaces: Go's error type is just a single-method interface.
Insight
Teaching error handling immediately after interfaces creates a powerful "aha" moment — everything from 0001 applies directly. errors.Is walks the error chain using interface satisfaction checks. Custom error types implement the error interface just like any other interface. Wrapping with %w creates an interface-compatible chain. This sequencing makes error handling feel natural rather than arbitrary.
The learner will immediately recognize error as the same pattern they just learned — "oh, it's just another interface" — which dramatically reduces cognitive load.
Consequences
- Lesson 0002 will teach error handling through the interface lens
- Should emphasize
errors.Is/errors.As— these are the most common in cloud-native code reviews - Should include Kubernetes-style error patterns (structured errors,
StatusError) - Reference doc: error-handling-cheat-sheet.html
- The nil interface trap from 0001 reappears here (checking
err != nilvs nil interface)