From 8e43e340a7b716fdae3bc86cfeb90fc0b5e68a03 Mon Sep 17 00:00:00 2001 From: MananTank Date: Thu, 24 Oct 2024 21:49:22 +0000 Subject: [PATCH] Handle isContractDeployed error on contract page (#5165) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem solved Short description of the bug fixed or feature added --- ## PR-Codex overview This PR focuses on improving error handling when checking if a contract is deployed. It ensures that if the contract check fails, it will not throw an error but instead return `false`. ### Detailed summary - Modified `isValidContract` assignment to handle errors gracefully by using `.catch(() => false)` instead of letting the promise reject. - Ensured that the flow continues to call `notFound()` if the contract is not valid. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../(dashboard)/(chain)/[chain_id]/[contractAddress]/layout.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/layout.tsx b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/layout.tsx index c95a69a7912..737f0b79c05 100644 --- a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/layout.tsx +++ b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/layout.tsx @@ -39,7 +39,7 @@ export default async function Layout(props: { } // check if the contract exists - const isValidContract = await isContractDeployed(contract); + const isValidContract = await isContractDeployed(contract).catch(() => false); if (!isValidContract) { // TODO - replace 404 with a better page to upsale deploy or other thirdweb products notFound();