File tree Expand file tree Collapse file tree
src/components/device-page/tabs Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -513,19 +513,23 @@ function parseMarkdown(md: string): ReactNode[] {
513513}
514514
515515async function fetchMd ( url : string ) : Promise < ReactNode [ ] > {
516- const res = await fetch ( url ) ;
516+ try {
517+ const res = await fetch ( url ) ;
517518
518- if ( ! res . ok ) {
519- return [ "Failed to fetch" ] ;
520- }
519+ if ( ! res . ok ) {
520+ return [ `Connection to GitHub ( ${ url } ) is required to access device docs.` , ` ${ res . status } - ${ res . statusText } ` ] ;
521+ }
521522
522- let text = ( await res . text ( ) ) . trim ( ) ;
523+ let text = ( await res . text ( ) ) . trim ( ) ;
523524
524- if ( text . startsWith ( "---" ) ) {
525- text = text . slice ( text . indexOf ( "---" , 3 ) + 3 ) ;
526- }
525+ if ( text . startsWith ( "---" ) ) {
526+ text = text . slice ( text . indexOf ( "---" , 3 ) + 3 ) ;
527+ }
527528
528- return parseMarkdown ( text ) ;
529+ return parseMarkdown ( text ) ;
530+ } catch ( error ) {
531+ return [ `Connection to GitHub (${ url } ) is required to access device docs.` , `${ error } ` ] ;
532+ }
529533}
530534
531535const DocsContent = memo ( ( { docsPromise } : { docsPromise : Promise < ReactNode [ ] > } ) => {
You can’t perform that action at this time.
0 commit comments