Standardise frontend hook fetch error handling and mark Task 12 done

This commit is contained in:
2026-03-22 10:17:15 +01:00
parent bf2abda595
commit 136f21ecbe
17 changed files with 62 additions and 45 deletions

View File

@@ -6,6 +6,7 @@
import { useCallback, useEffect, useState } from "react";
import { ApiError } from "../api/client";
import { handleFetchError } from "../utils/fetchError";
import { getSetupStatus, submitSetup } from "../api/setup";
import type {
SetupRequest,
@@ -44,9 +45,11 @@ export function useSetup(): UseSetupResult {
const resp = await getSetupStatus();
setStatus(resp);
} catch (err: unknown) {
const errorMessage = err instanceof Error ? err.message : "Failed to fetch setup status";
console.warn("Setup status check failed:", errorMessage);
setError(errorMessage);
const fallback = "Failed to fetch setup status";
handleFetchError(err, setError, fallback);
if (!(err instanceof DOMException && err.name === "AbortError")) {
console.warn("Setup status check failed:", err instanceof Error ? err.message : fallback);
}
} finally {
setLoading(false);
}