From 02212ba47896a7796de5ff040cfc9acb16b20fad Mon Sep 17 00:00:00 2001 From: counterweight Date: Sun, 21 Dec 2025 17:50:52 +0100 Subject: [PATCH] Make error handling consistent across frontend - Standardized all error handling to use ternary pattern - Changed if/else blocks to ternary operators for consistency - Updated booking, appointments, and admin appointments pages --- frontend/app/admin/appointments/page.tsx | 6 +----- frontend/app/appointments/page.tsx | 6 +----- frontend/app/booking/page.tsx | 6 +----- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/frontend/app/admin/appointments/page.tsx b/frontend/app/admin/appointments/page.tsx index 475fb85..5ce2390 100644 --- a/frontend/app/admin/appointments/page.tsx +++ b/frontend/app/admin/appointments/page.tsx @@ -202,11 +202,7 @@ export default function AdminAppointmentsPage() { await fetchAppointments(); setConfirmCancelId(null); } catch (err) { - if (err instanceof Error) { - setError(err.message); - } else { - setError("Failed to cancel appointment"); - } + setError(err instanceof Error ? err.message : "Failed to cancel appointment"); } finally { setCancellingId(null); } diff --git a/frontend/app/appointments/page.tsx b/frontend/app/appointments/page.tsx index ea13973..aa2f495 100644 --- a/frontend/app/appointments/page.tsx +++ b/frontend/app/appointments/page.tsx @@ -194,11 +194,7 @@ export default function AppointmentsPage() { await fetchAppointments(); setConfirmCancelId(null); } catch (err) { - if (err instanceof Error) { - setError(err.message); - } else { - setError("Failed to cancel appointment"); - } + setError(err instanceof Error ? err.message : "Failed to cancel appointment"); } finally { setCancellingId(null); } diff --git a/frontend/app/booking/page.tsx b/frontend/app/booking/page.tsx index 13811a4..a387dce 100644 --- a/frontend/app/booking/page.tsx +++ b/frontend/app/booking/page.tsx @@ -302,11 +302,7 @@ export default function BookingPage() { await fetchSlots(selectedDate); } } catch (err) { - if (err instanceof Error) { - setError(err.message); - } else { - setError("Failed to book appointment"); - } + setError(err instanceof Error ? err.message : "Failed to book appointment"); } finally { setIsBooking(false); }