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 9e8244bb71
commit 5024ab7241
55 changed files with 400 additions and 332 deletions
@@ -5,6 +5,7 @@ import { useAuth } from "@/hooks/useAuth";
import { apiFetch } from "@/lib/api";
import { useDismissingState } from "@/hooks/useDismissingState";
import { Copy, CreditCard, KeyRound, Trash2, Webhook } from "lucide-react";
import { errorMessage } from "@/lib/utils";
type Source = "db" | "env" | "none";
@@ -99,9 +100,9 @@ export function YocoTab({ active }: { active: boolean }) {
const res = await apiFetch<{ webhooks: YocoWebhook[] }>("/api/yoco/webhooks", { authToken: token });
setHooks(res.webhooks || []);
setHooksError(null);
} catch (e: any) {
} catch (e) {
setHooks([]);
setHooksError(e?.message || "Could not load webhooks from Yoco");
setHooksError(errorMessage(e) || "Could not load webhooks from Yoco");
}
}, [token]);
@@ -114,8 +115,8 @@ export function YocoTab({ active }: { active: boolean }) {
setHookUrl((prev) => prev || c.webhookUrl);
if (c.secretKeySource !== "none") await loadHooks();
else { setHooks([]); setHooksError(null); }
} catch (e: any) {
setMessage({ type: "err", text: e?.message || "Failed to load Yoco settings" });
} catch (e) {
setMessage({ type: "err", text: errorMessage(e) || "Failed to load Yoco settings" });
} finally {
setLoading(false);
}
@@ -130,8 +131,8 @@ export function YocoTab({ active }: { active: boolean }) {
const text = await fn();
setMessage({ type: "ok", text });
await load();
} catch (e: any) {
setMessage({ type: "err", text: e?.message || "Something went wrong" });
} catch (e) {
setMessage({ type: "err", text: errorMessage(e) || "Something went wrong" });
} finally {
setBusy(null);
}