- Home
- Skills
- Yanko Belov
- Code Craft
- Error Boundaries
error-boundaries_skill
- TypeScript
6
GitHub Stars
1
Bundled Files
3 weeks ago
Catalog Refreshed
2 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstart where the catalogue uses aiagentskills.
npx veilstart add skill yanko-belov/code-craft --skill error-boundaries- SKILL.md11.9 KB
Overview
This skill helps you decide where to catch errors by treating catches as architectural boundaries rather than random local guards. It teaches where to let errors propagate, where to translate or recover, and how to isolate failures for graceful degradation. Follow it to prevent hidden bugs and cascading failures while keeping business logic clean.
How this skill works
The guidance inspects your codebase for context transitions and recommends placing try/catch at those boundaries: entry points (HTTP, message consumers), external adapters, and UI component boundaries. It flags scattered catches inside services, repositories, or utility functions and suggests moving handling to top-level middleware, adapters, or error boundaries that can translate, log, and recover meaningfully.
When to use it
- Designing application architecture and error handling strategy
- Deciding whether to add a try/catch in a service, repo, or utility
- Isolating components so one failure doesn't crash unrelated features
- Implementing graceful degradation for optional features
- Mapping where errors should be translated, logged, or converted to domain errors
Best practices
- Place catches only at context transitions (HTTP middleware, adapters, UI ErrorBoundary)
- Let pure business logic, services, and repositories throw errors rather than swallow them
- Translate external errors to domain-specific errors in adapters, not in business code
- Use boundaries for fallbacks: only optional features get local try/catch for graceful degradation
- Avoid catch-and-rethrow unless you add genuinely useful context
Example use cases
- Top-level HTTP error middleware translates ValidationError, NotFoundError, UnauthorizedError to proper responses
- Payment gateway adapter catches provider errors and throws PaymentDeclinedError or PaymentServiceUnavailableError
- React ErrorBoundary isolates Dashboard and Sidebar so one UI failure doesn’t crash the whole app
- Recommendation service wrapped at boundary to log failures and return empty recommendations without failing the page
- Message queue consumer that catches, logs, and decides ack/nack at the entry boundary
FAQ
Generally no—services should throw and let a boundary handle translation or recovery. Only catch inside if you can perform a meaningful recovery that preserves program intent.
When is catch-and-rethrow acceptable?
Only when you add non-redundant context or translate an external error into a clear domain error that callers would otherwise not be able to act on.