Skip to content
Back to skills

Common Error Handling

ASecurity

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 t...

  • 584 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 5, 2026
developmentapidatabase

Works with

  • api

Security analysis

A100/100

Pro scans all 11 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill common-error-handling --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Common Error Handling?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Common Error Handling
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-common-error-handling-e5b2d527/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-common-error-handling-e5b2d527)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
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.md622 B
  • eval-1.with-skill.md1.9 KB
  • eval-2.baseline.md3.4 KB
  • eval-2.with-skill.md4.5 KB
  • eval-3.baseline.md704 B
  • eval-3.with-skill.md1.1 KB
  • trigger-1.md144 B
  • trigger-2.md162 B
  • trigger-3.md165 B
  • trigger-4.md186 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.