Standardise frontend hook fetch error handling and mark Task 12 done
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user