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
@@ -4,6 +4,7 @@ import React, { useEffect, useState } from "react";
import { Wifi, WifiOff, CloudUpload, Lock } from "lucide-react";
import { apiFetch } from "@/lib/api";
import type { OtherLock } from "./useOfflineScanning";
import { errorMessage } from "@/lib/utils";
type Offline = ReturnType<typeof import("./useOfflineScanning").useOfflineScanning>;
@@ -38,8 +39,8 @@ export function OfflineScanPanel({ offline, token, eventId, eventTitle, sectionI
try {
const n = await offline.enable(eventId, eventTitle, sectionId, sectionName);
onInfo(`Offline mode on — ${n} ticket(s) downloaded. You can keep scanning without a connection.`);
} catch (e: any) {
onError(e?.message || "Couldn't turn on offline mode");
} catch (e) {
onError(errorMessage(e) || "Couldn't turn on offline mode");
} finally {
setBusy(false);
}
@@ -49,8 +50,8 @@ export function OfflineScanPanel({ offline, token, eventId, eventTitle, sectionI
try {
await offline.release();
onInfo("Offline mode ended and the section is unlocked.");
} catch (e: any) {
onError(e?.message || "Couldn't end offline mode");
} catch (e) {
onError(errorMessage(e) || "Couldn't end offline mode");
} finally {
setBusy(false);
}
@@ -59,8 +60,8 @@ export function OfflineScanPanel({ offline, token, eventId, eventTitle, sectionI
try {
const r = await offline.sync();
if (r) onInfo(`Synced ${r.accepted} scan(s)${r.conflicts ? ` — ${r.conflicts} need a supervisor to review` : ""}.`);
} catch (e: any) {
onError(e?.message || "Sync failed — scans are kept on this device and will retry.");
} catch (e) {
onError(errorMessage(e) || "Sync failed — scans are kept on this device and will retry.");
}
};