diff --git a/services/web/app/src/Features/LinkedFiles/LinkedFilesController.js b/services/web/app/src/Features/LinkedFiles/LinkedFilesController.js index 76f065a628..b6f06ee1e9 100644 --- a/services/web/app/src/Features/LinkedFiles/LinkedFilesController.js +++ b/services/web/app/src/Features/LinkedFiles/LinkedFilesController.js @@ -21,6 +21,7 @@ const logger = require('logger-sharelatex') const _ = require('underscore') const LinkedFilesHandler = require('./LinkedFilesHandler') const { + CompileFailedError, UrlFetchFailedError, InvalidUrlError, OutputFileFetchFailedError, @@ -152,6 +153,10 @@ module.exports = LinkedFilesController = { .send( 'Sorry, the source project is not yet imported to Overleaf v2. Please import it to Overleaf v2 to refresh this file' ) + } else if (error instanceof CompileFailedError) { + return res + .status(422) + .send(res.locals.translate('generic_linked_file_compile_error')) } else if (error instanceof OutputFileFetchFailedError) { return res.status(404).send('Could not get output file') } else if (error instanceof UrlFetchFailedError) { diff --git a/services/web/app/src/Features/LinkedFiles/LinkedFilesErrors.js b/services/web/app/src/Features/LinkedFiles/LinkedFilesErrors.js index f433bf8116..5a1457d51b 100644 --- a/services/web/app/src/Features/LinkedFiles/LinkedFilesErrors.js +++ b/services/web/app/src/Features/LinkedFiles/LinkedFilesErrors.js @@ -4,6 +4,7 @@ class UrlFetchFailedError extends BackwardCompatibleError {} class InvalidUrlError extends BackwardCompatibleError {} +class CompileFailedError extends BackwardCompatibleError {} class OutputFileFetchFailedError extends BackwardCompatibleError {} class AccessDeniedError extends BackwardCompatibleError {} @@ -27,6 +28,7 @@ class RemoteServiceError extends BackwardCompatibleError {} class FileCannotRefreshError extends BackwardCompatibleError {} module.exports = { + CompileFailedError, UrlFetchFailedError, InvalidUrlError, OutputFileFetchFailedError, diff --git a/services/web/app/src/Features/LinkedFiles/ProjectOutputFileAgent.js b/services/web/app/src/Features/LinkedFiles/ProjectOutputFileAgent.js index 3c7b52a66a..21979e7924 100644 --- a/services/web/app/src/Features/LinkedFiles/ProjectOutputFileAgent.js +++ b/services/web/app/src/Features/LinkedFiles/ProjectOutputFileAgent.js @@ -21,6 +21,7 @@ const ClsiManager = require('../Compile/ClsiManager') const ProjectFileAgent = require('./ProjectFileAgent') const _ = require('underscore') const { + CompileFailedError, BadDataError, AccessDeniedError, BadEntityTypeError, @@ -268,7 +269,7 @@ module.exports = ProjectOutputFileAgent = { return callback(err) } if (status !== 'success') { - return callback(new OutputFileFetchFailedError()) + return callback(new CompileFailedError()) } const outputFile = _.find( outputFiles, diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 09182fe92f..9d208056ee 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -97,6 +97,7 @@ "from_provider": "", "full_doc_history": "", "full_screen": "", + "generic_linked_file_compile_error": "", "generic_something_went_wrong": "", "get_collaborative_benefits": "", "git_bridge_modal_description": "", diff --git a/services/web/frontend/js/features/file-tree/components/file-tree-create/error-message.js b/services/web/frontend/js/features/file-tree/components/file-tree-create/error-message.js index cd08f0b588..1fdeef2566 100644 --- a/services/web/frontend/js/features/file-tree/components/file-tree-create/error-message.js +++ b/services/web/frontend/js/features/file-tree/components/file-tree-create/error-message.js @@ -52,6 +52,13 @@ export default function ErrorMessage({ error }) { ) + case 'linked-project-compile-error': + return ( + + {t('generic_linked_file_compile_error')} + + ) + default: // TODO: convert error.response.data to an error key and try again? // return error diff --git a/services/web/frontend/js/features/file-tree/hooks/use-project-output-files.js b/services/web/frontend/js/features/file-tree/hooks/use-project-output-files.js index 150e6fc4b8..9ab207de05 100644 --- a/services/web/frontend/js/features/file-tree/hooks/use-project-output-files.js +++ b/services/web/frontend/js/features/file-tree/hooks/use-project-output-files.js @@ -34,7 +34,7 @@ export function useProjectOutputFiles(projectId) { setData(filteredFiles.sort(alphabetical)) } else { - setError(true) + setError('linked-project-compile-error') } }) .catch(error => setError(error)) diff --git a/services/web/frontend/js/features/file-view/components/file-view-header.js b/services/web/frontend/js/features/file-view/components/file-view-header.js index 7b847647aa..5187439d38 100644 --- a/services/web/frontend/js/features/file-view/components/file-view-header.js +++ b/services/web/frontend/js/features/file-view/components/file-view-header.js @@ -76,7 +76,7 @@ export default function FileViewHeader({ file, storeReferencesKeys }) { }) .catch(err => { setRefreshing(false) - setRefreshError(err.message) + setRefreshError(err.data?.message || err.message) }) .finally(() => { if ( diff --git a/services/web/locales/en.json b/services/web/locales/en.json index a6f963d784..c40341a3fc 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -1,4 +1,5 @@ { + "generic_linked_file_compile_error": "This project's output files are not available because it failed to compile. Please open the project to see the compilation error details.", "chat_error": "Could not load chat messages, please try again.", "reconnect": "Try again", "no_pdf_error_title": "No PDF",