-
Notifications
You must be signed in to change notification settings - Fork 0
fix(serve): differentiate HTTP error codes instead of catch-all 500 #379
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
All ledger/database errors in edda-serve become `AppError::Internal` → HTTP 500. There is no distinction between:
- Transient errors (database locked, connection timeout) → should be 503
- Data validation errors (missing field from ledger query) → could be 422
- Not found via ledger (project doesn't exist) → should be 404
Current `AppError` has 5 variants (Validation/400, NotFound/404, Conflict/409, Unauthorized/401, Internal/500) but only Validation and Internal are used in most handlers. The other variants exist but are underutilized.
Scope
- Audit each handler's `?` propagation to identify where more specific status codes apply
- Add error classification at the handler level:
- Ledger `open()` fails → 404 if project not found, 500 if I/O error
- Query returns empty → 404 (not 500)
- Database locked → 503 with Retry-After header
- Consider adding `AppError::ServiceUnavailable` variant for transient failures
Notes
- `AppError` definition at `edda-serve/src/lib.rs:72`
- `IntoResponse` impl at same file
- This pairs well with the .context() work (GH-XXX) — better errors + better codes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request