> common-error-handling
Cross-cutting standards for error design, response shapes, error codes, and boundary placement. (triggers: **/*.service.ts, **/*.handler.ts, **/*.controller.ts, **/*.go, **/*.java, **/*.kt, **/*.py, error handling, exception, try catch, error boundary, error response, error code, throw)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/common-error-handling?format=md"Error Handling Standards
Priority: P1 (OPERATIONAL)
🏗 Error Architecture
- API Layer: Map domain errors to HTTP responses globally.
- Domain Layer: Throw pure business errors. NO HTTP status codes here.
- Infra Layer: Wrap 3rd-party exceptions. Do NOT leak raw DB errors to API.
- Standard Shape: APIs must return a standardized JSON envelope (
code,message,traceId).
📦 Error Mechanics
- Wrap: Add context (
fmt.Errorf("process: %w", err),new Error('msg', { cause })). - Replace: Only when original error leaks sensitive details.
- Error Codes: Use
SCREAMING_SNAKE_CASEIDs (ORDER_PAYMENT_FAILED).
🚫 Anti-Patterns
- Swallowing Errors: Never
catch(e) {}without logging or re-throwing. - Stack Traces: Never expose stack traces in API responses.
- Generic 500s: Use
400with specific details for validation instead of 500.
References
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)