skills/practices/error-handling/SKILL.md
Error handling patterns for consistent, meaningful error management across the stack. Use when implementing any feature that can fail.
npx skillsauth add devjarus/coding-agent error-handlingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
catch block that continues execution as if nothing happened is a bug waiting to surface in production.System boundaries are where external data enters your system: HTTP requests, message queue consumers, CLI arguments, file uploads.
{ "error": "VALIDATION_FAILED", "field": "email", "message": "must be a valid email address" }
Business logic is the core of your application. Errors here are domain events, not infrastructure surprises.
Error tells the caller nothing. InsufficientFundsError, OrderAlreadyShippedError, and UserNotFoundError convey meaning and can be handled selectively.throw new PaymentProcessingError("failed to charge card", { cause: originalError, orderId })
Infrastructure code talks to databases, external APIs, message queues, and file systems. These components fail transiently.
Avoid these patterns — they make bugs harder to find and production incidents harder to diagnose.
| Anti-pattern | Why it's harmful |
|---|---|
| Empty catch block | Silently discards the error. The program continues in an invalid state. |
| Catch-and-rethrow without context | Loses the original error message and stack trace. |
| Returning null or undefined for failure | Forces every caller to remember to check, and they often won't. |
| Log-and-throw | Produces duplicate log entries and confusing stack traces. Log or throw, not both. |
| Generic error messages | "Something went wrong" is not actionable for users or on-call engineers. |
| Catching Error to ignore specific errors | Catches too broadly; suppresses unexpected errors alongside the expected one. |
testing
Multi-source research method — decompose a question, fan out parallel investigators, interleaved-think each result, verify claims adversarially, synthesize a cited answer. Use for breadth-heavy research, stack comparisons, "which approach wins" questions.
testing
Decide when to use unit vs integration vs e2e tests, and when to mock vs use the real thing per dependency. Dependency injection is the enabler — without it you end up monkey-patching imports. Apply when writing tests of any kind.
development
Test-driven development process — write failing test, implement to pass, refactor. Use when implementing any feature or fixing bugs.
development
Patterns for sharing types, API contracts, and validation schemas between frontend and backend. Use when multiple domains consume the same data shapes to prevent contract drift.