@@ -21,6 +21,7 @@ import { AuthorsList } from '../../../components'
2121import { Deposition } from '../../../types/zenodo'
2222import { fetchDataDeposition , fetchPreprintIdentifier } from '../../../actions'
2323import ErrorOrTrack from './error-or-track'
24+ import { alertOnError } from '../../../actions/server-utils'
2425
2526pdfjs . GlobalWorkerOptions . workerSrc = `//unpkg.com/pdfjs-dist@${ pdfjs . version } /build/pdf.worker.min.mjs`
2627
@@ -111,10 +112,6 @@ const PreprintViewer = ({
111112 } )
112113 } , [ track , preprint . pk , submissionType ] )
113114
114- const onDocumentLoadSuccess = ( pdf : PDFDocumentProxy ) : void => {
115- setPdf ( pdf )
116- }
117-
118115 useEffect ( ( ) => {
119116 if ( pdf && ! hidePdfOutline ) {
120117 pdf . getOutline ( ) . then ( setPdfOutline ) . catch ( console . error )
@@ -201,7 +198,18 @@ const PreprintViewer = ({
201198 < div ref = { containerRef } style = { { width : '100%' } } >
202199 < Document
203200 file = { preprint . versions [ 0 ] . public_download_url }
204- onLoadSuccess = { onDocumentLoadSuccess }
201+ onLoadSuccess = { ( pdf : PDFDocumentProxy ) => setPdf ( pdf ) }
202+ onLoadError = { ( error ) =>
203+ window . location . hostname . includes ( 'cdrxiv.org' )
204+ ? alertOnError ( {
205+ endpoint : preprint . versions [ 0 ] . public_download_url ,
206+ status : 'n/a' ,
207+ statusText : 'unknown' ,
208+ method : 'GET' ,
209+ apiError : error . message ,
210+ } )
211+ : undefined
212+ }
205213 loading = {
206214 < Flex
207215 sx = { {
0 commit comments