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
@@ -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;