Common Error Handling
ASecurityReplace every empty catch with deliberate handling: ```ts try { await processOrder(); } catch (error) { throw new Error("process order failed", { cause: error }); } ``` Choose the appropriate action: - Log the error when intentionally continuing, including useful context. - Handle it with an explicit fallback or recovery branch. - Wrap it with context (`new Error("...", { cause: error })` or `fmt.Errorf("process: %w", err)`). - Rethrow it when the caller or boundary must decide. - Map it at t...
- 584 stars
- 0 votes
- 0 copies
- 4 views
- Added September 5, 2026
Works with
Security analysis
100/100Pro scans all 11 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill common-error-handling --agent claude-codeAre you the author of Common Error Handling?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-common-error-handling-e5b2d527)Replace every empty catch with deliberate handling:
```ts
try {
await processOrder();
} catch (error) {
throw new Error("process order failed", { cause: error });
}
```
Choose the appropriate action:
- Log the error when intentionally continuing, including useful context.
- Handle it with an explicit fallback or recovery branch.
- Wrap it with context (`new Error("...", { cause: error })` or `fmt.Errorf("process: %w", err)`).
- Rethrow it when the caller or boundary must decide.
- Map it at the API boundary to a standardized JSON error envelope and HTTP response.
- Keep domain errors framework-independent—never place HTTP status codes there.
- In infrastructure code, wrap third-party or database exceptions; do not leak raw DB errors.
- Use `SCREAMING_SNAKE_CASE` error codes such as `ORDER_PAYMENT_FAILED`.
- Return specific `400` validation errors instead of generic `500` responses.
- Never expose stack traces in API responses.
Do not leave `catch(e) {}` or silently ignore failures. If an error is intentionally discarded, document why and at minimum log or explicitly handle that branch.
Files in this skill
- eval-1.baseline.md
- eval-1.with-skill.md
- eval-2.baseline.md
- eval-2.with-skill.md
- eval-3.baseline.md
- eval-3.with-skill.md
- trigger-1.md
- trigger-2.md
- trigger-3.md
- trigger-4.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.