…rror
When users access URLs with invalid slug parameters (e.g., non-existent
sizes or layouts), the parseBoardRouteParamsWithSlugs function throws an
error. Previously this caused a 500 Server Components render error.
This change wraps the main function bodies of affected pages and layouts
in try-catch blocks, catching parsing errors and returning a proper 404
page via Next.js notFound() instead of propagating the error.
Affected files:
- list/page.tsx, list/layout.tsx
- layout.tsx (angle layout)
- play/[climb_uuid]/page.tsx, play/layout.tsx
- create/page.tsx
- import/page.tsx
Fixes Sentry issue BOARDSESH-4
Summary
Added comprehensive error handling to all board-related route pages and layouts by wrapping server-side logic in try-catch blocks and calling
notFound()when errors occur. This ensures graceful error handling instead of unhandled promise rejections.Key Changes
create/page.tsx): Wrapped route parameter parsing and board initialization in try-catch, callsnotFound()on errorimport/page.tsx): Added error handling around MoonBoard import logic withnotFound()fallbacklayout.tsx): Wrapped board details fetching and parameter parsing with error handlinglist/layout.tsx): Added try-catch around board details initializationlist/page.tsx): Wrapped climb search and board details fetching with error handlingplay/[climb_uuid]/page.tsx): Added error handling for climb fetching and board initializationplay/layout.tsx): Wrapped board details fetching with error handlingImplementation Details
notFound()fromnext/navigationis called in catch blocks to return a 404 response