mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-07-26 18:38:30 +00:00
Update 1.2.2.2 beta
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user