Context
API errors return inconsistent formats and non-descriptive messages. Developers struggle to handle errors programmatically.
Current Limitation/Problem
Error codes are ad-hoc strings. The same error type may return different codes from different endpoints. There is no centralized error code registry.
Expected Outcome
A unified error code system with structured error responses, a centralized registry, auto-generated developer documentation, and SDK-friendly error types.
Acceptance Criteria
- Define error code format:
ERR_<CATEGORY>_<SPECIFIC> (e.g., ERR_PAYMENT_INSUFFICIENT_FUNDS)
- Centralized error code registry with description, HTTP status, and resolution hints
- Standardized error response:
{ error: { code, message, details, requestId } }
- All endpoints return errors in standard format
- Error code discoverability: GET /api/errors returns full registry
- SDK generates typed error classes from registry
- OpenAPI integration: documented error responses per endpoint
- Error categorization: auth, validation, payment, blockchain, rate_limit, internal
- Error code deprecation with sunset timeline
Technical Scope
packages/error-codes/ - error code registry package
backend/src/middleware/error-handler.ts - standardized error response
backend/src/errors/ - error classes
packages/sdk/src/errors/ - typed error classes
- Auto-generation of error documentation
- Edge cases: error wrapping, sensitive information leakage, 3rd-party error mapping
Context
API errors return inconsistent formats and non-descriptive messages. Developers struggle to handle errors programmatically.
Current Limitation/Problem
Error codes are ad-hoc strings. The same error type may return different codes from different endpoints. There is no centralized error code registry.
Expected Outcome
A unified error code system with structured error responses, a centralized registry, auto-generated developer documentation, and SDK-friendly error types.
Acceptance Criteria
ERR_<CATEGORY>_<SPECIFIC>(e.g.,ERR_PAYMENT_INSUFFICIENT_FUNDS){ error: { code, message, details, requestId } }Technical Scope
packages/error-codes/- error code registry packagebackend/src/middleware/error-handler.ts- standardized error responsebackend/src/errors/- error classespackages/sdk/src/errors/- typed error classes