express · Easy · error contract
Several route handlers expose different error shapes. Clients cannot distinguish a validation error from a retryable dependency failure without parsing prose.
Task
Normalize a service failure into the public error envelope without exposing internal messages.
Contract
Input is {kind,field,retryAfterMs,requestId}. Return {status,body,headers}. Supported kinds are validation, unauthorized, conflict, dependency and unknown.
Acceptance criteria
- Map each known kind to its documented status and code.
- Include field only for validation.
- Round retry-after up to whole seconds for dependency failures.
- Expose requestId but never internal text.
Constraints
- Do not mutate caller-owned input.
- Keep the supplied framework adapter and public contract unchanged.
- Add candidate tests for at least one boundary not covered by the public cases.
Editable files
src/repair.js— Task-specific state or service boundarytests/candidate.test.js— Candidate-authored regression