Skip to content

Commit 8e1c847

Browse files
committed
feat: improve self service with troubleshooting tips and improved error messages in explore component
1 parent 86978b0 commit 8e1c847

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

public/locales/en/explore.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@
7070
},
7171
"errors": {
7272
"BlockFetchTimeoutError": "Failed to fetch content in {timeout}s. Please refresh the page to retry or try a different CID.",
73-
"checkIpfsNetwork": "Check content availability on IPFS Network"
73+
"BlockFetchError": "Failed to fetch content: {error}. This could mean the content is not available on the network or there are connectivity issues.",
74+
"CidSyntaxError": "Invalid CID format: {cid}. Please ensure you are using a valid CID.",
75+
"checkIpfsNetwork": "Check content availability on IPFS Network",
76+
"troubleshootingTips": {
77+
"title": "Troubleshooting Tips",
78+
"refresh": "Try refreshing the page",
79+
"checkConnection": "Check your internet connection",
80+
"tryLater": "Try again later - the content may still be propagating through the network",
81+
"checkCidSyntax": "Verify that your CID is formatted correctly or that your CAR file is valid"
82+
}
7483
}
7584
}
Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,43 @@
11
import React from 'react'
22
import { useTranslation } from 'react-i18next'
3-
import { BlockFetchTimeoutError } from '../../lib/errors'
3+
import { useExplore } from '../../providers/explore'
44
import type IpldExploreError from '../../lib/errors'
55

66
export interface IpldExploreErrorComponentProps {
77
error: IpldExploreError | null
88
}
99

1010
export function IpldExploreErrorComponent ({ error }: IpldExploreErrorComponentProps): JSX.Element | null {
11+
const { exploreState } = useExplore()
12+
const { path } = exploreState
13+
const [cid] = path?.split('/') ?? []
1114
const { t } = useTranslation('explore', { keyPrefix: 'errors' })
1215
if (error == null) return null
1316

14-
const isBlockError = error instanceof BlockFetchTimeoutError
15-
17+
// more self service
1618
return (
1719
<div className='bg-red white pa3 lh-copy'>
1820
<div>{error.toString(t)}</div>
19-
{isBlockError && (
21+
{cid != null && <><div className='mt3'>
22+
<h4 className='ma0 mb2'>{t('troubleshootingTips.title')}</h4>
23+
<ul className='ma0 pl3'>
24+
<li>{t('troubleshootingTips.refresh')}</li>
25+
<li>{t('troubleshootingTips.checkConnection')}</li>
26+
<li>{t('troubleshootingTips.tryLater')}</li>
27+
<li>{t('troubleshootingTips.checkCidSyntax')}</li>
28+
</ul>
29+
</div>
2030
<div className='mt2'>
2131
<a
22-
href={`https://check.ipfs.network/#/ipfs/${error.cid ?? ''}`}
32+
href={`https://check.ipfs.network/?cid=${cid}`}
2333
target="_blank"
2434
rel="noopener noreferrer"
2535
className='white underline hover-white'
2636
>
2737
{t('checkIpfsNetwork')}
2838
</a>
2939
</div>
30-
)}
40+
</>}
3141
</div>
3242
)
3343
}

src/lib/errors.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type TFunction } from 'i18next'
22

33
export default class IpldExploreError extends Error {
4-
constructor (protected readonly options: Record<string, string | number>) {
4+
constructor (private readonly options: Record<string, string | number>) {
55
super()
66
this.name = this.constructor.name
77
}
@@ -19,10 +19,6 @@ export default class IpldExploreError extends Error {
1919
toString (t: TFunction<'translation', 'translation'>): string {
2020
return t(this.name, this.options)
2121
}
22-
23-
get cid (): string | undefined {
24-
return this.options.cid as string | undefined
25-
}
2622
}
2723

2824
export class BlockFetchTimeoutError extends IpldExploreError {}

0 commit comments

Comments
 (0)