What problem does it solve?
Go projects often struggle with propagating errors with sufficient context, leading to debugging challenges. This Skill promotes wrapping errors with context, using sentinel errors, and designing custom error types to improve debuggability and API clarity.
Core Features & Use Cases
- Wrapping errors with context using fmt.Errorf and %w to preserve the error chain.
- Defining sentinel errors for expected failure modes and checking with errors.Is.
- Creating custom error types to include structured information and richer messages.
- Use cases: library authors exposing clear errors, API handlers returning enriched errors, and services enforcing consistent error handling.
Quick Start
Audit the codebase to adopt the conventions: replace plain error returns with context-wrapped errors, introduce sentinel errors for common failures, and add small custom error types where structured data helps debugging. Example: return fmt.Errorf("creating user %s: %w", email, err)