Error Handling
Purpose
Create predictable, secure, debuggable error behavior across the application.
Project Stack
FastAPI, Python, Next.js, React, TypeScript.
Operating Principles
- Handle expected failures explicitly.
- Do not expose stack traces or internal secrets to users.
- Preserve useful diagnostic information in server-side logs.
- Use consistent API error shapes.
- Distinguish validation, authentication, authorization, not-found, conflict, dependency, and unexpected failures.
- Do not catch broad exceptions unless there is a deliberate recovery strategy.
- Never silently ignore errors.
- Frontend code must provide useful user-facing failure states.
- Retry only operations that are safe to retry.
- Test failure paths as deliberately as success paths.
Required Workflow
- Reproduce the failure.
- Capture the exact error.
- Identify where the error crosses a system boundary.
- Decide whether it is expected or unexpected.
- Implement the smallest appropriate handling.
- Test the original failure.
- Test neighboring failure cases.
- Review logging and information disclosure.
Evidence Rules
Use the strongest available evidence in this order:
- Runtime behavior
- Automated test results
- Type checking, linting, and build results
- Installed package/source behavior
- Official framework or library documentation
- Repository configuration
- Static code inspection
- General model knowledge
Never report an assumption as a verified result.
Tool Selection
- Use Filesystem MCP for repository exploration and file inspection.
- Use Context7 for current, version-specific library/framework documentation.
- Use Fetch when official documentation or public web resources need to be retrieved.
- Use Playwright for browser behavior, frontend interaction, forms, authentication flows, and UI verification.
- Use GitHub CLI for repository, branch, pull request, issue, workflow, and CI operations.
- Prefer the smallest tool set that establishes reliable evidence.
Failure Handling
When something fails:
- Reproduce the failure.
- Capture the exact error.
- Identify the failing layer.
- Check whether the failure is environmental, dependency-related, configuration-related, or caused by application code.
- Research uncertain behavior using authoritative sources.
- Apply the smallest appropriate fix.
- Reproduce the original failure again.
- Run regression checks.
- Inspect the final diff.
Do not hide failures by weakening tests, suppressing errors, deleting evidence, or claiming success without verification.
Security
- Never expose secrets.
- Never commit credentials.
- Treat all external input as untrusted.
- Preserve authentication and authorization boundaries.
- Avoid leaking internal implementation details through errors.
- Review security implications whenever the skill touches users, data, credentials, networking, or deployment.
Completion Criteria
A task using this skill is complete only when:
- The requested behavior is implemented.
- Existing project conventions are preserved.
- Relevant static checks pass.
- Relevant tests pass or their absence is explicitly reported.
- Browser verification is performed when the task affects user-facing behavior.
- Security implications have been considered.
- The final diff has been inspected.
- Verified facts are clearly distinguished from assumptions or remaining uncertainty.
1---2name: error-handling3description: Error Handling4---5# Error Handling67## Purpose89Create predictable, secure, debuggable error behavior across the application.1011## Project Stack1213FastAPI, Python, Next.js, React, TypeScript.1415## Operating Principles16171. Handle expected failures explicitly.182. Do not expose stack traces or internal secrets to users.193. Preserve useful diagnostic information in server-side logs.204. Use consistent API error shapes.215. Distinguish validation, authentication, authorization, not-found, conflict, dependency, and unexpected failures.226. Do not catch broad exceptions unless there is a deliberate recovery strategy.237. Never silently ignore errors.248. Frontend code must provide useful user-facing failure states.259. Retry only operations that are safe to retry.2610. Test failure paths as deliberately as success paths.2728## Required Workflow29301. Reproduce the failure.312. Capture the exact error.323. Identify where the error crosses a system boundary.334. Decide whether it is expected or unexpected.345. Implement the smallest appropriate handling.356. Test the original failure.367. Test neighboring failure cases.378. Review logging and information disclosure.3839## Evidence Rules4041Use the strongest available evidence in this order:42431. Runtime behavior442. Automated test results453. Type checking, linting, and build results464. Installed package/source behavior475. Official framework or library documentation486. Repository configuration497. Static code inspection508. General model knowledge5152Never report an assumption as a verified result.5354## Tool Selection5556- Use Filesystem MCP for repository exploration and file inspection.57- Use Context7 for current, version-specific library/framework documentation.58- Use Fetch when official documentation or public web resources need to be retrieved.59- Use Playwright for browser behavior, frontend interaction, forms, authentication flows, and UI verification.60- Use GitHub CLI for repository, branch, pull request, issue, workflow, and CI operations.61- Prefer the smallest tool set that establishes reliable evidence.6263## Failure Handling6465When something fails:66671. Reproduce the failure.682. Capture the exact error.693. Identify the failing layer.704. Check whether the failure is environmental, dependency-related, configuration-related, or caused by application code.715. Research uncertain behavior using authoritative sources.726. Apply the smallest appropriate fix.737. Reproduce the original failure again.748. Run regression checks.759. Inspect the final diff.7677Do not hide failures by weakening tests, suppressing errors, deleting evidence, or claiming success without verification.7879## Security8081- Never expose secrets.82- Never commit credentials.83- Treat all external input as untrusted.84- Preserve authentication and authorization boundaries.85- Avoid leaking internal implementation details through errors.86- Review security implications whenever the skill touches users, data, credentials, networking, or deployment.8788## Completion Criteria8990A task using this skill is complete only when:9192- The requested behavior is implemented.93- Existing project conventions are preserved.94- Relevant static checks pass.95- Relevant tests pass or their absence is explicitly reported.96- Browser verification is performed when the task affects user-facing behavior.97- Security implications have been considered.98- The final diff has been inspected.99- Verified facts are clearly distinguished from assumptions or remaining uncertainty.