Error handling
Use for error handling, error types, propagation, retries, user messages, and recovery.From its SKILL.md
npx -y skills add kreek/consult --skill error-handlingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.6 KB, ~1.0k tokens by cl100k_base, as published. Nobody here has run it
Error Handling
Iron Law
ERRORS CARRY CONTEXT. NEVER CATCH WITHOUT HANDLING OR RE-RAISING.
When to Use
- Designing or reviewing typed errors, exceptions, Result/Either flows, domain error boundaries, wrapping, retries, remote-call failures, panics, user-facing errors, or swallowed failures.
When NOT to Use
- Security-specific failure shape; pair with
security. - REST status-code taxonomy or public API error schema; use
api. - Observability of errors in production; pair with
observability.
Core Ideas
- Failure is part of the function contract.
- Add context at each boundary; preserve the original cause. Catch only where you can decide: recover, translate, retry, or terminate.
- Translate failures when the caller's contract changes. Domain, infrastructure, API, CLI, and UI errors should not leak across boundaries unchanged.
- Expected failures are typed: use named exception classes,
discriminated unions, enums, or structured
Resultvariants for recoverable cases. - Classify errors as user-correctable, transient, or programmer/system faults.
- User-facing messages are safe and actionable; internal errors keep diagnostic detail under a correlation ID.
- Remote calls declare timeout, retry, idempotency, and dependency-failure behavior together. Retry transient failures in one layer with a capped budget and jitter/backoff.
- Panics/assertions are for impossible states and process boundaries, not routine control flow.
Workflow
- Identify where the error originates and where the decision can be made. Choose return-value errors, exceptions, Result/Either, or process termination based on caller contract.
- Define the domain error vocabulary for expected failures. Translate it when crossing into another domain or public interface.
- Wrap with operation, resource, and correlation context. Translate to user/API/CLI shape at the boundary.
- For each remote dependency, define timeout, retry budget, idempotency requirement, and failure behavior before coding the caller.
- Test at least one failure path for each public operation that can fail.
Verification
- Every catch/rescue/except either recovers, translates, retries safely, or re-raises with context.
- Expected failures use typed error classes, structured Result/Either variants, enums, or discriminated unions; no recoverable path raises/throws bare strings or anonymous generic errors.
- Domain, infrastructure, API, CLI, and UI errors are translated at their boundaries instead of leaking across unchanged.
- Failure-capable public functions document failure in their contract; wrapped errors preserve underlying cause.
- User-facing errors are actionable without exposing stack traces, SQL, file paths, hostnames, secrets, or auth-enumeration clues; diagnostic detail is reachable by correlation ID.
- Retries apply only to idempotent/transient failures with a capped budget, jitter/backoff, and one retrying layer.
- Remote dependencies define finite timeouts and explicit circuit breaker, bulkhead, load-shedding, or fail-fast behavior.
- Tests cover representative failure paths.
Tripwires
| Trigger | Do this instead | False alarm |
|---|---|---|
| "Log and continue is fine" | Decide whether to recover, translate, retry, or terminate. | Best-effort telemetry failure with an explicit drop policy. |
| "This can't fail in practice" | Declare the failure-capable contract and test a representative failure. | Compile-time impossible state enforced by type/value construction. |
| "Swallow at the boundary" | Translate for the caller and preserve the cause for diagnostics. | Security boundary deliberately hides details while logging correlation. |
| "We'll add remote-call protection later" | Define timeout, retry budget, idempotency guard, and dependency-failure behavior now. | Local in-memory call with no blocking I/O. |
Handoffs
- Use
securityfor auth, secrets, validation, fail-closed behavior, and information disclosure. - Use
apifor REST status-code selection, Problem Details/JSON:API error contracts, public idempotency-key contracts, OpenAPI response docs, and compatibility. - Use
domain-modelingwhen the error vocabulary is part of the domain model or state machine. - Use
observabilityfor correlation IDs, logs, traces, and error-rate alerts, including critical dependency health.
References
../api/references/rest-error-status-codes.md: local REST error status-code decision tree.
What ships with it: 1 file
208 B alongside SKILL.md
agents/
- openai.yaml208 B