Standardise frontend hook fetch error handling and mark Task 12 done
This commit is contained in:
@@ -12,11 +12,13 @@ import {
|
||||
flushLogs,
|
||||
previewLog,
|
||||
reloadConfig,
|
||||
restartFail2Ban,
|
||||
testRegex,
|
||||
updateGlobalConfig,
|
||||
updateJailConfig,
|
||||
updateServerSettings,
|
||||
} from "../api/config";
|
||||
import { handleFetchError } from "../utils/fetchError";
|
||||
import type {
|
||||
AddLogPathRequest,
|
||||
GlobalConfig,
|
||||
@@ -65,9 +67,7 @@ export function useJailConfigs(): UseJailConfigsResult {
|
||||
setTotal(resp.total);
|
||||
})
|
||||
.catch((err: unknown) => {
|
||||
if (err instanceof Error && err.name !== "AbortError") {
|
||||
setError(err.message);
|
||||
}
|
||||
handleFetchError(err, setError, "Failed to fetch jail configs");
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -128,9 +128,7 @@ export function useJailConfigDetail(name: string): UseJailConfigDetailResult {
|
||||
setJail(resp.jail);
|
||||
})
|
||||
.catch((err: unknown) => {
|
||||
if (err instanceof Error && err.name !== "AbortError") {
|
||||
setError(err.message);
|
||||
}
|
||||
handleFetchError(err, setError, "Failed to fetch jail config");
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -191,9 +189,7 @@ export function useGlobalConfig(): UseGlobalConfigResult {
|
||||
fetchGlobalConfig()
|
||||
.then(setConfig)
|
||||
.catch((err: unknown) => {
|
||||
if (err instanceof Error && err.name !== "AbortError") {
|
||||
setError(err.message);
|
||||
}
|
||||
handleFetchError(err, setError, "Failed to fetch global config");
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -251,9 +247,7 @@ export function useServerSettings(): UseServerSettingsResult {
|
||||
setSettings(resp.settings);
|
||||
})
|
||||
.catch((err: unknown) => {
|
||||
if (err instanceof Error && err.name !== "AbortError") {
|
||||
setError(err.message);
|
||||
}
|
||||
handleFetchError(err, setError, "Failed to fetch server settings");
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user