Type caught errors as unknown in the frontend

Replace `catch (e: any)` with `catch (e)` and read the message through a
new errorMessage() helper. ApiError.data gets a real type, and
useDismissingState's setter keeps one identity across renders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 11:10:00 +02:00
co-authored by Claude Opus 5.5
parent 958a5a5950
commit 619b5b9a93
55 changed files with 400 additions and 332 deletions
+7 -6
View File
@@ -5,6 +5,7 @@ import { useAuth } from "@/hooks/useAuth";
import { apiFetch, API_BASE } from "@/lib/api";
import { useDismissingState } from "@/hooks/useDismissingState";
import { DatabaseBackup, Download } from "lucide-react";
import { errorMessage } from "@/lib/utils";
interface BackupEntry {
filename: string;
@@ -38,8 +39,8 @@ export function BackupsTab({ active }: { active: boolean }) {
]);
setBackups(list || []);
setRetainCount(allSettings?.backup_retain_count || "14");
} catch (e: any) {
setMessage({ type: "err", text: e?.message || "Failed to load backups" });
} catch (e) {
setMessage({ type: "err", text: errorMessage(e) || "Failed to load backups" });
} finally {
setLoading(false);
}
@@ -51,8 +52,8 @@ export function BackupsTab({ active }: { active: boolean }) {
try {
await apiFetch("/api/settings", { method: "PUT", authToken: token, body: { backup_retain_count: retainCount } });
setMessage({ type: "ok", text: "Retention setting saved." });
} catch (e: any) {
setMessage({ type: "err", text: e?.message || "Failed to save retention setting" });
} catch (e) {
setMessage({ type: "err", text: errorMessage(e) || "Failed to save retention setting" });
} finally {
setSavingRetain(false);
}
@@ -68,8 +69,8 @@ export function BackupsTab({ active }: { active: boolean }) {
const res = await apiFetch<{ filename: string }>("/api/backups/run", { method: "POST", authToken: token });
setMessage({ type: "ok", text: `Backup created: ${res.filename}` });
await load();
} catch (e: any) {
setMessage({ type: "err", text: e?.message || "Backup failed" });
} catch (e) {
setMessage({ type: "err", text: errorMessage(e) || "Backup failed" });
} finally {
setRunning(false);
}