From cfc41e6c4e14a169a2186dfc7138fd93195f38b6 Mon Sep 17 00:00:00 2001 From: Mikael Siidorow Date: Thu, 18 Jan 2024 21:26:50 +0200 Subject: [PATCH] add error handling for external api requests --- .../src/components/events-display/index.tsx | 7 ++++- apps/web/src/dictionaries/en.json | 3 ++ apps/web/src/dictionaries/fi.json | 3 ++ apps/web/src/lib/api/external/helpers.ts | 29 +++++++++++++++++++ apps/web/src/lib/api/external/ilmomasiina.ts | 12 ++++++-- 5 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 apps/web/src/lib/api/external/helpers.ts diff --git a/apps/web/src/components/events-display/index.tsx b/apps/web/src/components/events-display/index.tsx index 305c5aa3..e153a40b 100644 --- a/apps/web/src/components/events-display/index.tsx +++ b/apps/web/src/components/events-display/index.tsx @@ -76,9 +76,14 @@ async function EventList({ }) { const events = await fetchEvents(); + if (!events.ok) { + console.warn("Failed to fetch events from Ilmomasiina", events.error); + return null; + } + return (