From fdec1bc2be1d47e4e7362ad4ff767bbd2c755290 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Wed, 29 May 2024 13:22:18 -0400 Subject: [PATCH 1/3] Silently fail when a given chain doesn't support ENS, it's expected and fine and shouldn't result in a Sentry "uncaught exception" report --- src/hooks/DAO/useGetDAOName.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hooks/DAO/useGetDAOName.ts b/src/hooks/DAO/useGetDAOName.ts index 274a13195d..01e214e1c3 100644 --- a/src/hooks/DAO/useGetDAOName.ts +++ b/src/hooks/DAO/useGetDAOName.ts @@ -22,7 +22,13 @@ const getDAOName = async ({ throw new Error('Public client not available'); } - const ensName = await publicClient.getEnsName({ address: address }); + const ensName = await publicClient.getEnsName({ address: address }).catch((error: Error) => { + if (error.name === 'ChainDoesNotSupportContract') { + // sliently fail, this is fine + return; + } + throw error; + }); if (ensName) { return ensName; } From 93475be5e80be019d37e201a5a866200af93a2a8 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Wed, 29 May 2024 13:22:48 -0400 Subject: [PATCH 2/3] Add link to discussion about it --- src/hooks/DAO/useGetDAOName.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hooks/DAO/useGetDAOName.ts b/src/hooks/DAO/useGetDAOName.ts index 01e214e1c3..99c0af2a18 100644 --- a/src/hooks/DAO/useGetDAOName.ts +++ b/src/hooks/DAO/useGetDAOName.ts @@ -24,7 +24,8 @@ const getDAOName = async ({ const ensName = await publicClient.getEnsName({ address: address }).catch((error: Error) => { if (error.name === 'ChainDoesNotSupportContract') { - // sliently fail, this is fine + // Sliently fail, this is fine. + // https://github.com/wevm/viem/discussions/781 return; } throw error; From 62cb4153cfe6f86546ecc6391c07bfe8cc0c90c1 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Wed, 29 May 2024 13:25:42 -0400 Subject: [PATCH 3/3] Oops, don't early exit when we get the chain ens not supported error --- src/hooks/DAO/useGetDAOName.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/DAO/useGetDAOName.ts b/src/hooks/DAO/useGetDAOName.ts index 99c0af2a18..2c48eaaf47 100644 --- a/src/hooks/DAO/useGetDAOName.ts +++ b/src/hooks/DAO/useGetDAOName.ts @@ -26,9 +26,9 @@ const getDAOName = async ({ if (error.name === 'ChainDoesNotSupportContract') { // Sliently fail, this is fine. // https://github.com/wevm/viem/discussions/781 - return; + } else { + throw error; } - throw error; }); if (ensName) { return ensName;