Designs robust error handling strategies — typed errors, error boundaries, observability hooks.
Click to play with sound.
---
name: Error Handling
description: Design typed, observable, recoverable error handling.
---
# Error Handling
Treat errors as a first-class part of the design, not an afterthought.
## Principles
1. Distinguish expected failures (validation, not-found) from bugs (nulls, type errors).
2. Model expected failures as values; let truly exceptional bugs throw.
3. Fail fast and loud in development; degrade gracefully in production.
4. Every error that reaches a user should be actionable; every error logged should be diagnosable.
## Typed errors
```ts
type Result<T, E> = { ok: true; value: T } | { ok: false; error: E };
class NotFoundError extends Error {
readonly code = 'NOT_FOUND';
constructor(readonly resource: string) { super(\`${resource} not found\`); }
}… install to load the full skillSign in to rate and review this skill.
No reviews yet. Be the first to review this skill.