Update 1.2.2.2 beta

This commit is contained in:
MacRimi
2026-06-23 11:19:04 +02:00
parent 6ab9d4ca27
commit 93553574b3
5 changed files with 133 additions and 38 deletions

View File

@@ -138,6 +138,12 @@ export async function fetchApi<T>(endpoint: string, options?: RequestInit): Prom
// return `{error: "..."}` on failure (e.g. /api/vms/<id>/control
// includes the pvesh stderr — telling the user "no space left on
// device" is infinitely more useful than the raw status text).
//
// We also attach the FULL parsed JSON body to the thrown Error
// as `.body` so callers that want the optional `details` /
// `suggestion` fields (e.g. /api/node/metrics) can render them
// without re-fetching. Callers that just read `err.message`
// keep working exactly as before.
try {
const ct = response.headers.get("content-type") || ""
if (ct.includes("application/json")) {
@@ -145,7 +151,10 @@ export async function fetchApi<T>(endpoint: string, options?: RequestInit): Prom
const detail =
(body && (body.error || body.message)) || ""
if (detail) {
throw new Error(detail)
const e: Error & { body?: unknown; status?: number } = new Error(detail)
e.body = body
e.status = response.status
throw e
}
}
} catch (parseErr) {