From c580bda6edb3c764509edf6c1847c49bbfe93e6e Mon Sep 17 00:00:00 2001 From: Kai Chappell Date: Fri, 27 Jun 2025 20:27:54 +0100 Subject: [PATCH] fix(frontend): handle API errors gracefully --- frontend/src/app/categories/page.tsx | 15 ++++++++++++++- frontend/src/app/patterns/page.tsx | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/categories/page.tsx b/frontend/src/app/categories/page.tsx index f0ef69a..e567108 100644 --- a/frontend/src/app/categories/page.tsx +++ b/frontend/src/app/categories/page.tsx @@ -2,7 +2,20 @@ import { getCategories } from "@/lib/api"; import Link from "next/link"; export default async function CategoriesPage() { - const { items: categories } = await getCategories(); + let categories; + try { + const response = await getCategories(); + categories = response.items; + } catch { + return ( +
+

Categories

+

+ Unable to load categories. Please try again later. +

+
+ ); + } return (
diff --git a/frontend/src/app/patterns/page.tsx b/frontend/src/app/patterns/page.tsx index 6d9d5a0..c77b626 100644 --- a/frontend/src/app/patterns/page.tsx +++ b/frontend/src/app/patterns/page.tsx @@ -2,7 +2,20 @@ import { getPatterns } from "@/lib/api"; import Link from "next/link"; export default async function PatternsPage() { - const { items: patterns } = await getPatterns(); + let patterns; + try { + const response = await getPatterns(); + patterns = response.items; + } catch { + return ( +
+

Algorithmic Patterns

+

+ Unable to load patterns. Please try again later. +

+
+ ); + } return (