1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-10 12:16:49 +00:00

fix(api): an error's status says what it is, and its body is always {"detail"}

- libvirt errors all answered 400. A VM, pool or volume the host does not
  have now answers 404, a volume in use 409 (vrtManager.util.InUse) and a
  host that cannot be reached 503, which a client may retry.
- A template's power on or cycle and a stopped pool answered
  {"status": ...} with 409; they answer {"detail": ...}, as every other
  refusal. The schema documents these 409s (ErrorSerializer).
- The volume list and a volume of a stopped pool answered 200 with an
  empty list or a made-up volume; they answer 409.
- An API URL that names nothing answered the HTML error page; it answers
  a JSON 404 after the API's authentication.
- A session that must change its password was redirected to the HTML
  form; an API request of it gets the JSON 403 a token gets.
This commit is contained in:
catborise 2026-11-07 00:19:13 +03:00
parent 9d22d48a85
commit 0610c23a34
14 changed files with 145 additions and 36 deletions

View file

@ -49,6 +49,10 @@ class OperationError(libvirt.libvirtError):
return render(self.text, self.values, gettext)
class InUse(OperationError):
"""An object something still uses cannot be changed or deleted."""
class ConnectionFailed(OperationError):
"""The host could not be connected to; the message may name it and how it
is reached."""