Error handling
Skill undp/carbon-footprint-program/.claude/skills/error-handling
Error handling across API and web. Use when throwing, shaping, or translating errors — the shared error classes, error-response schema, Prisma error helpers, and the frontend error-message mapping.From its SKILL.md
npx -y skills add undp/carbon-footprint-program --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
- 0 stars0 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
1.3 KB, as published. Nobody here has run it
Error Handling
- API errors: throw custom error classes from
apps/api/src/errors/(e.g.,DataIntegrityError,EmptyResourceError,DatabaseUniqueConstraintViolationError). Services can throw these at any point — Fastify's error handler plugin catches them automatically and normalizes them into a standard response. Always reuse the existing error classes instead of defining new feature-specific ones; the shared set covers the common cases (not found, unique constraint violation, data integrity, empty resource, config error). - Error response schema: use
ApiErrorResponseSchemafromapps/api/src/commonSchemas/errors.tsfor error responses in route schemas (e.g.,response: { 404: ApiErrorResponseSchema }). - Prisma errors: use helpers like
extractP2002Fields()fromapps/api/src/errors/to handle unique constraint violations with meaningful messages. - Frontend error messages:
getApiErrorMessage()inapps/web/src/utils/getApiErrorMessage.tsmaps API error codes to user-facing Spanish messages.