Adds ApiError and ErrorCode to the common crate to establish the shared provisioning API error envelope used by all future endpoints.
Changes#
crates/common/src/error.rs— new module:ErrorCodeenum (#[non_exhaustive], Wave 0–2 set) serialized asSCREAMING_SNAKE_CASEstringsApiError { code, message, details }serialized to{ "error": { "code": "...", "message": "...", "details": {} } }impl IntoResponse for ApiError— maps each code to its HTTP statusdetailsisOption<serde_json::Value>, omitted from JSON when absent
crates/common/Cargo.toml— addedaxum,serde_jsondepscrates/common/src/lib.rs— re-exportsApiError,ErrorCode
Tests#
4 unit tests covering:
- Correct envelope shape (nested
errorkey) detailsincluded when present, absent whenNone- All 8 error code → HTTP status mappings
Notes#
ErrorCode is #[non_exhaustive] so external crates must handle _ in match arms. New variants for later waves can be added without breaking existing callers.