result-pattern
Installation
SKILL.md
Result Pattern
Wraps operation outcomes in Result<T> representing success or failure. Alternative to throwing exceptions for expected errors—provides explicit error paths and forces consumers to handle errors.
When to Use
- Expected business errors (validation failed, user not found, unauthorized)
- Chaining multiple operations that can fail
- Type-safe error handling across layers
- API endpoints that need different HTTP status codes per error type
Don't use for:
- Truly unexpected errors (null pointer, out of memory) → throw exceptions
- Simple getters that can't fail
- Internal private helpers