From 551076771fbcefd4790c153458850c611646d762 Mon Sep 17 00:00:00 2001 From: titix Date: Wed, 4 Sep 2024 10:55:54 -0300 Subject: [PATCH] fix: chain paths handle errors --- cypress/e2e/navigation.cy.ts | 2 +- src/pages/[chain]/index.tsx | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/navigation.cy.ts b/cypress/e2e/navigation.cy.ts index 72fe681..54154c2 100644 --- a/cypress/e2e/navigation.cy.ts +++ b/cypress/e2e/navigation.cy.ts @@ -22,9 +22,9 @@ describe('Navigation tests', () => { cy.getByTestId('search-bar').find('input').type('324'); cy.getByTestId('chain-row').should('be.visible').click(); - cy.url().should('include', '/324'); cy.getByTestId('chain-id').should('be.visible').and('contain', '324'); + cy.url().should('include', '/324'); cy.getByTestId('home-breadcrumb').click(); cy.url().should('eq', 'http://localhost:5173/'); diff --git a/src/pages/[chain]/index.tsx b/src/pages/[chain]/index.tsx index 7fb2755..dc16fea 100644 --- a/src/pages/[chain]/index.tsx +++ b/src/pages/[chain]/index.tsx @@ -41,8 +41,18 @@ export const getStaticPaths: GetStaticPaths = async () => { }; } - const ecosystemData = await fetchEcosystemData(); - const chains = ecosystemData.zkChains; + let ecosystemData; + try { + ecosystemData = await fetchEcosystemData(); + } catch (error) { + console.error('Failed to fetch ecosystem data:', error); + return { + paths: [], + fallback: true, + }; + } + + const chains = ecosystemData.zkChains || []; const paths = SUPPORTED_LANGUAGES.flatMap((locale) => chains.map((chain: EcosystemChainData) => ({