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
@@ -7,6 +7,7 @@ import { CouponCodeField, AppliedCoupon } from "@/components/shared/CouponCodeFi
import { AttendeeNamesEditor, AttendeeEntries, TicketDelivery, attendeesPayload, consentDetailsMissing } from "@/components/shared/AttendeeNamesEditor";
import { JoinWaitlistButton } from "@/components/events/JoinWaitlistButton";
import { analyticsSessionId } from "@/lib/analytics";
import { errorMessage } from "@/lib/utils";
// Tiered low-stock threshold — mirrors events/[id]/page.tsx
function lowStockThreshold(stockLimit: number): number {
@@ -395,8 +396,8 @@ export default function RegisterForm({ event: baseEvent }: { event: Event }) {
body: { eventId, options: items, waitlistToken, analyticsSessionId: analyticsSessionId(), ...(namedAttendees().length > 0 ? { attendees: namedAttendees(), ticketDelivery: delivery } : {}) },
});
if (res?.id) window.location.href = `/registration/success?registrationId=${encodeURIComponent(res.id)}&totalDue=${encodeURIComponent((res.totalDueComputed ?? payable).toFixed(2))}`;
} catch (e: any) {
setError(e?.message || "Registration failed");
} catch (e) {
setError(errorMessage(e) || "Registration failed");
} finally {
setCreatingRegistration(false);
}
@@ -439,8 +440,8 @@ export default function RegisterForm({ event: baseEvent }: { event: Event }) {
}
window.location.href = next;
}
} catch (e: any) {
setError(e?.message || "Registration failed");
} catch (e) {
setError(errorMessage(e) || "Registration failed");
} finally {
setCreatingRegistration(false);
}
@@ -475,8 +476,8 @@ export default function RegisterForm({ event: baseEvent }: { event: Event }) {
window.location.href = `/registration/success?registrationId=${encodeURIComponent(res.id)}&totalDue=0.00`;
}
}
} catch (e: any) {
setError(e?.message || "Registration failed");
} catch (e) {
setError(errorMessage(e) || "Registration failed");
} finally {
setCreatingRegistration(false);
}