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
@@ -8,6 +8,7 @@ import { useRouter, useSearchParams } from "next/navigation";
import { formatDate } from "@/lib/date";
import { QrImage } from "@/components/shared/QrImage";
import { Ticket } from "lucide-react";
import { errorMessage } from "@/lib/utils";
function EventTicketsContent() {
const { token, user } = useAuth();
@@ -55,8 +56,8 @@ function EventTicketsContent() {
}`
);
}
} catch (e: any) {
setError(e?.message || "Failed to load events");
} catch (e) {
setError(errorMessage(e) || "Failed to load events");
}
})();
}, [token]);
@@ -80,8 +81,8 @@ function EventTicketsContent() {
{ authToken: token }
);
setTickets(list);
} catch (e: any) {
setError(e?.message || "Failed to load tickets");
} catch (e) {
setError(errorMessage(e) || "Failed to load tickets");
} finally {
setLoading(false);
}
@@ -10,6 +10,7 @@ import { QrCode } from "lucide-react";
import { useOfflineScanning } from "@/components/scanner/useOfflineScanning";
import { OfflineScanPanel } from "@/components/scanner/OfflineScanPanel";
import type { SnapshotTicket } from "@/lib/offlineScan";
import { errorMessage } from "@/lib/utils";
export default function TicketScanningPage() {
const router = useRouter();
@@ -158,8 +159,8 @@ export default function TicketScanningPage() {
let preview: any;
try {
preview = await apiFetch<any>(`/api/tickets/scan-preview/${encodeURIComponent(text)}`, { authToken: token });
} catch (pe: any) {
setErrorModal(pe?.message || 'Failed to validate ticket');
} catch (pe) {
setErrorModal(errorMessage(pe) || 'Failed to validate ticket');
return;
}
@@ -202,8 +203,8 @@ export default function TicketScanningPage() {
setConfirmQty(remaining);
setConfirmQtyRaw(String(remaining));
setConfirmModal({ qrCode: text, ticket: preview, remaining });
} catch (e: any) {
setErrorModal(e?.message || "Failed to scan ticket");
} catch (e) {
setErrorModal(errorMessage(e) || "Failed to scan ticket");
}
}
@@ -237,9 +238,9 @@ export default function TicketScanningPage() {
if (offlineTicket) {
try {
await offline.scanLocally(offlineTicket, qty);
} catch (e: any) {
} catch (e) {
setSuccessModal(null);
setErrorModal(e?.message || "Couldn't save the scan on this device");
setErrorModal(errorMessage(e) || "Couldn't save the scan on this device");
}
return;
}
@@ -260,10 +261,10 @@ export default function TicketScanningPage() {
},
});
refreshStatsAndRecent();
} catch (e: any) {
} catch (e) {
setSuccessModal(null);
setScanInfo(null);
const raw = e?.message || "Failed to scan ticket";
const raw = errorMessage(e) || "Failed to scan ticket";
try {
const parsed = JSON.parse(raw);
const msg: string | undefined = parsed?.message;