mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
The HTTP API mapped every ApiError to 500 Internal Server Error, so an API client could not distinguish "the VM has not been created yet" from a genuine server-side failure without parsing the error message text. Derive the HTTP status code from the error itself in error_response(): errors whose root cause is VmError::VmNotCreated or VmMissingConfig are now reported as 404 Not Found, regardless of which API action surfaced them. The existing 400 (bad request) and 429 (too many requests) mappings are preserved. State-conflict errors such as VmNotRunning would ideally map to 409 Conflict, but micro_http's StatusCode has no Conflict variant, so they remain 500 for now. Fixes: #7774 Signed-off-by: Max Makarov <maxpain@linux.com> Assisted-by: Claude:claude-opus-4-8 [Claude Code]