Skip to content

Commit 3d2548c

Browse files
authored
fix: ensure every catch logs the underlying error to console (#382)
* fix: ensure every error toast logs the underlying error to console * fix: ensure remaining `catch` clauses always `console.error(...)`
1 parent 7a5340b commit 3d2548c

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

src/components/notifications/AppExplorer/AppCard/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const AppCard: React.FC<AppCardProps> = ({
4949
userPubkey &&
5050
activeSubscriptions.some(element => {
5151
const projectURL = new URL(url)
52+
5253
return projectURL.hostname === element.metadata.appDomain
5354
})
5455
const logoURL = logo || '/fallback.svg'
@@ -74,6 +75,7 @@ const AppCard: React.FC<AppCardProps> = ({
7475
appDomain: new URL(url).host
7576
})
7677
} catch (error) {
78+
console.error(error)
7779
setSubscribing(false)
7880
showErrorMessageToast(`Failed to subscribe to ${name}`)
7981
}

src/contexts/W3iContext/hooks/notifyHooks.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ export const useNotifyState = (w3iProxy: Web3InboxProxy, proxyReady: boolean) =>
4646
})
4747
}, [notifyClient, userPubkey, proxyReady])
4848

49-
// it takes time for handshake (watch subscriptions) to complete
50-
// load in progress state using interval until it is
49+
/*
50+
* It takes time for handshake (watch subscriptions) to complete
51+
* load in progress state using interval until it is
52+
*/
5153
useEffect(() => {
5254
if(watchSubscriptionsComplete) {
5355
return noop;
@@ -78,6 +80,7 @@ export const useNotifyState = (w3iProxy: Web3InboxProxy, proxyReady: boolean) =>
7880
setRegistered(identityKey)
7981
refreshNotifyState()
8082
} catch (error) {
83+
console.error(error)
8184
setRegisterMessage(null)
8285
}
8386
}

src/pages/widget/Subscribe/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ const WidgetSubscribe: React.FC = () => {
4343
appDomain: new URL(dappOrigin).host
4444
})
4545
} catch (error) {
46-
showErrorMessageToast('Failed to subscribe')
46+
console.error(error)
47+
showErrorMessageToast(`Failed to subscribe to ${dappOrigin}`)
4748
} finally {
4849
setIsSubscribing(false)
4950
}

src/utils/hooks/useNotifyProjects.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,20 @@ const useNotifyProjects = () => {
4141
url: item.dapp_url,
4242
icon: item.image_url?.md ?? '/fallback.svg',
4343
colors: item.metadata?.colors,
44-
isVerified: item.is_verified || item.isVerified ? true : false,
44+
isVerified: Boolean(item.is_verified || item.isVerified),
4545
isFeatured: item.is_featured,
4646
isComingSoon: item.is_coming_soon
4747
}))
4848
.filter(app => Boolean(app.name))
4949

5050
notifyApps.concat(COMING_SOON_PROJECTS)
5151

52-
setLoading(false)
5352
setProjects(notifyApps)
5453
} catch (error) {
55-
setLoading(false)
54+
console.error(error)
5655
setProjects([])
56+
} finally {
57+
setLoading(false)
5758
}
5859
}
5960

src/utils/projects.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ export async function fetchFeaturedProjects<T>() {
1111

1212
try {
1313
const discoverProjectsData = await fetch(explorerUrlFeatured)
14-
.then(res => res.json())
15-
.catch(err => console.log({ featuredProjects: err }))
14+
.then(async res => res.json())
15+
.catch(err => console.error({ featuredProjects: err }))
1616
const discoverProjects = Object.values(discoverProjectsData.projects)
1717

1818
return {
1919
data: discoverProjects as T
2020
}
2121
} catch (error) {
22-
throw new Error('Error fetching featured projects')
22+
throw new Error(`Error fetching featured projects: ${error}`)
2323
}
2424
}
2525

@@ -35,13 +35,13 @@ export async function fetchDomainProjects<T>(domain: string) {
3535
explorerUrlAppDomain.searchParams.set('appDomain', domain)
3636

3737
try {
38-
const domainProjectsData = await fetch(explorerUrlAppDomain).then(res => res.json())
38+
const domainProjectsData = await fetch(explorerUrlAppDomain).then(async res => res.json())
3939
domainProject = domainProjectsData.data as T
4040

4141
return {
4242
data: domainProject
4343
}
4444
} catch (error) {
45-
throw new Error('Error fetching domain project')
45+
throw new Error(`Error fetching projects for domain: ${error}`)
4646
}
4747
}

0 commit comments

Comments
 (0)