From 111cce4ca4405e585214afe3cc5aec4ef5e8e71a Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Mon, 7 Nov 2022 14:23:53 +0000 Subject: [PATCH] Merge pull request #10299 from overleaf/jpa-nicer-warning-message-for-missing-pdf [web] show a nicer warning message for missing pdf exceptions GitOrigin-RevId: f519ec145d7ff4fe725241742fb66a1defdd257e --- .../web/frontend/extracted-translations.json | 2 ++ .../pdf-preview/components/pdf-js-viewer.js | 8 +++-- .../components/pdf-preview-error.js | 32 +++++++++++++++++++ services/web/locales/en.json | 2 ++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index c85d2a25a4..e67975e80a 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -327,6 +327,7 @@ "labs_program_not_participating": "", "last_modified": "", "last_name": "", + "last_resort_trouble_shooting_guide": "<0>", "last_updated_date_by_x": "", "latex_help_guide": "", "layout": "", @@ -596,6 +597,7 @@ "showing_x_results_of_total": "", "something_went_wrong_loading_pdf_viewer": "", "something_went_wrong_rendering_pdf": "", + "something_went_wrong_rendering_pdf_expected": "<0>", "something_went_wrong_server": "", "somthing_went_wrong_compiling": "", "sort_by": "", diff --git a/services/web/frontend/js/features/pdf-preview/components/pdf-js-viewer.js b/services/web/frontend/js/features/pdf-preview/components/pdf-js-viewer.js index 8284f6b922..3a1c60e93c 100644 --- a/services/web/frontend/js/features/pdf-preview/components/pdf-js-viewer.js +++ b/services/web/frontend/js/features/pdf-preview/components/pdf-js-viewer.js @@ -128,10 +128,14 @@ function PdfJsViewer({ url, pdfFile }) { setStartFetch(performance.now()) const abortController = new AbortController() - const handleFetchError = () => { + const handleFetchError = err => { if (abortController.signal.aborted) return // The error is already logged at the call-site with additional context. - setError('rendering-error') + if (err instanceof pdfJsWrapper.PDFJS.MissingPDFException) { + setError('rendering-error-expected') + } else { + setError('rendering-error') + } } pdfJsWrapper .loadDocument({ url, pdfFile, abortController, handleFetchError }) diff --git a/services/web/frontend/js/features/pdf-preview/components/pdf-preview-error.js b/services/web/frontend/js/features/pdf-preview/components/pdf-preview-error.js index 0d0257fad0..6ffd1c60a1 100644 --- a/services/web/frontend/js/features/pdf-preview/components/pdf-preview-error.js +++ b/services/web/frontend/js/features/pdf-preview/components/pdf-preview-error.js @@ -10,7 +10,39 @@ import StopOnFirstErrorBadge from '../../../shared/components/stop-on-first-erro function PdfPreviewError({ error }) { const { t } = useTranslation() + const { startCompile } = useCompileContext() + switch (error) { + case 'rendering-error-expected': + return ( + + +