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 { CouponCodeField, AppliedCoupon } from "@/components/shared/CouponCodeFi
import { TransferTicketModal, canOfferTransfer } from "@/components/shared/TransferTicketModal";
import { AttendeeNamesEditor, AttendeeEntries, TicketDelivery, attendeesPayload, consentDetailsMissing } from "@/components/shared/AttendeeNamesEditor";
import { DoorOpen, UserPlus, CreditCard, CheckSquare, Ticket, RotateCcw, type LucideIcon } from "lucide-react";
import { errorMessage } from "@/lib/utils";
type Mode = "registration" | "payment" | "checkin" | "tickets" | "refund";
@@ -259,8 +260,8 @@ export default function AtTheDoorPage() {
body: { code: doorCoupon.code },
});
message = `Registration updated — code ${doorCoupon.code} applied`;
} catch (ce: any) {
message = `Registration updated, but the code wasn't applied: ${ce?.message || "unknown error"}`;
} catch (ce) {
message = `Registration updated, but the code wasn't applied: ${errorMessage(ce) || "unknown error"}`;
}
}
setShowOptionsModal(false);
@@ -291,8 +292,8 @@ export default function AtTheDoorPage() {
if (res?.couponError) setError(`Registered, but the code wasn't applied: ${res.couponError}`);
handleRegistrationCreated(res);
}
} catch (e: any) {
setError(e?.message || "Failed");
} catch (e) {
setError(errorMessage(e) || "Failed");
} finally {
setConfirming(false);
}
@@ -336,8 +337,8 @@ export default function AtTheDoorPage() {
let freshReg = reg;
try {
freshReg = await apiFetch<any>(`/api/registrations/${reg.id}`, { authToken: token });
} catch (e: any) {
setError(e?.message || "Failed to load latest registration data");
} catch (e) {
setError(errorMessage(e) || "Failed to load latest registration data");
return;
}
@@ -725,8 +726,8 @@ function DoorPaymentPanel({ token, registration, onSuccess, setError }: any) {
onSuccess(updated, true); // 🎯 partial payment flow
}
} catch (e: any) {
setError(e?.message || "Payment failed");
} catch (e) {
setError(errorMessage(e) || "Payment failed");
} finally {
setSaving(false);
}
@@ -1137,8 +1138,8 @@ function DoorCheckInPanel({ token, eventId, registration, setError, setInfo }: a
res?.remaining > 0 ? ` — ${res.remaining} remaining` : " — fully checked in"
}. Confirmation sent.`);
await load();
} catch (e: any) {
setError(e?.message || "Check-in failed");
} catch (e) {
setError(errorMessage(e) || "Check-in failed");
} finally {
setSubmittingId(null);
}
@@ -1421,8 +1422,8 @@ function DonationModal({ open, onClose, user, token, eventId, onSuccess, setErro
setAmount("");
onClose();
} catch (e: any) {
setError(e?.message || "Donation failed");
} catch (e) {
setError(errorMessage(e) || "Donation failed");
} finally {
setSaving(false);
}
@@ -1523,8 +1524,8 @@ function SendTicketsModal({ open, onClose, token, registration, setError, setInf
});
setLocalInfo("Tickets sent successfully.");
setTimeout(() => { setLocalInfo(""); onClose(); }, 7000);
} catch (e: any) {
setLocalError(e?.message || "Failed to send tickets");
} catch (e) {
setLocalError(errorMessage(e) || "Failed to send tickets");
} finally {
setSending(false);
}
@@ -1645,8 +1646,8 @@ function RefundModal({ open, onClose, token, registration, maxRefund, onRefunded
// Re-fetch registration to get updated status & payments
const updated = await apiFetch<any>(`/api/registrations/${registration.id}`, { authToken: token });
onRefunded(updated);
} catch (e: any) {
setLocalError(e?.message || "Refund failed.");
} catch (e) {
setLocalError(errorMessage(e) || "Refund failed.");
} finally {
setSaving(false);
}