浏览代码

Merge pull request #4341 from overleaf/jpa-ta-error-message-linked-files

[misc] better error msg for failed compiles when linking project files

GitOrigin-RevId: cac3d9e5cf25918dc8f5e259d106c145235c15c1
Alexandre Bourdin 5 年之前
父节点
当前提交
4b4ed6147c

+ 5 - 0
services/web/app/src/Features/LinkedFiles/LinkedFilesController.js

@@ -21,6 +21,7 @@ const logger = require('logger-sharelatex')
 const _ = require('underscore')
 const _ = require('underscore')
 const LinkedFilesHandler = require('./LinkedFilesHandler')
 const LinkedFilesHandler = require('./LinkedFilesHandler')
 const {
 const {
+  CompileFailedError,
   UrlFetchFailedError,
   UrlFetchFailedError,
   InvalidUrlError,
   InvalidUrlError,
   OutputFileFetchFailedError,
   OutputFileFetchFailedError,
@@ -152,6 +153,10 @@ module.exports = LinkedFilesController = {
         .send(
         .send(
           'Sorry, the source project is not yet imported to Overleaf v2. Please import it to Overleaf v2 to refresh this file'
           '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) {
     } else if (error instanceof OutputFileFetchFailedError) {
       return res.status(404).send('Could not get output file')
       return res.status(404).send('Could not get output file')
     } else if (error instanceof UrlFetchFailedError) {
     } else if (error instanceof UrlFetchFailedError) {

+ 2 - 0
services/web/app/src/Features/LinkedFiles/LinkedFilesErrors.js

@@ -4,6 +4,7 @@ class UrlFetchFailedError extends BackwardCompatibleError {}
 
 
 class InvalidUrlError extends BackwardCompatibleError {}
 class InvalidUrlError extends BackwardCompatibleError {}
 
 
+class CompileFailedError extends BackwardCompatibleError {}
 class OutputFileFetchFailedError extends BackwardCompatibleError {}
 class OutputFileFetchFailedError extends BackwardCompatibleError {}
 
 
 class AccessDeniedError extends BackwardCompatibleError {}
 class AccessDeniedError extends BackwardCompatibleError {}
@@ -27,6 +28,7 @@ class RemoteServiceError extends BackwardCompatibleError {}
 class FileCannotRefreshError extends BackwardCompatibleError {}
 class FileCannotRefreshError extends BackwardCompatibleError {}
 
 
 module.exports = {
 module.exports = {
+  CompileFailedError,
   UrlFetchFailedError,
   UrlFetchFailedError,
   InvalidUrlError,
   InvalidUrlError,
   OutputFileFetchFailedError,
   OutputFileFetchFailedError,

+ 2 - 1
services/web/app/src/Features/LinkedFiles/ProjectOutputFileAgent.js

@@ -21,6 +21,7 @@ const ClsiManager = require('../Compile/ClsiManager')
 const ProjectFileAgent = require('./ProjectFileAgent')
 const ProjectFileAgent = require('./ProjectFileAgent')
 const _ = require('underscore')
 const _ = require('underscore')
 const {
 const {
+  CompileFailedError,
   BadDataError,
   BadDataError,
   AccessDeniedError,
   AccessDeniedError,
   BadEntityTypeError,
   BadEntityTypeError,
@@ -268,7 +269,7 @@ module.exports = ProjectOutputFileAgent = {
             return callback(err)
             return callback(err)
           }
           }
           if (status !== 'success') {
           if (status !== 'success') {
-            return callback(new OutputFileFetchFailedError())
+            return callback(new CompileFailedError())
           }
           }
           const outputFile = _.find(
           const outputFile = _.find(
             outputFiles,
             outputFiles,

+ 1 - 0
services/web/frontend/extracted-translations.json

@@ -97,6 +97,7 @@
   "from_provider": "",
   "from_provider": "",
   "full_doc_history": "",
   "full_doc_history": "",
   "full_screen": "",
   "full_screen": "",
+  "generic_linked_file_compile_error": "",
   "generic_something_went_wrong": "",
   "generic_something_went_wrong": "",
   "get_collaborative_benefits": "",
   "get_collaborative_benefits": "",
   "git_bridge_modal_description": "",
   "git_bridge_modal_description": "",

+ 7 - 0
services/web/frontend/js/features/file-tree/components/file-tree-create/error-message.js

@@ -52,6 +52,13 @@ export default function ErrorMessage({ error }) {
           </DangerMessage>
           </DangerMessage>
         )
         )
 
 
+      case 'linked-project-compile-error':
+        return (
+          <DangerMessage>
+            {t('generic_linked_file_compile_error')}
+          </DangerMessage>
+        )
+
       default:
       default:
         // TODO: convert error.response.data to an error key and try again?
         // TODO: convert error.response.data to an error key and try again?
         // return error
         // return error

+ 1 - 1
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))
             setData(filteredFiles.sort(alphabetical))
           } else {
           } else {
-            setError(true)
+            setError('linked-project-compile-error')
           }
           }
         })
         })
         .catch(error => setError(error))
         .catch(error => setError(error))

+ 1 - 1
services/web/frontend/js/features/file-view/components/file-view-header.js

@@ -76,7 +76,7 @@ export default function FileViewHeader({ file, storeReferencesKeys }) {
       })
       })
       .catch(err => {
       .catch(err => {
         setRefreshing(false)
         setRefreshing(false)
-        setRefreshError(err.message)
+        setRefreshError(err.data?.message || err.message)
       })
       })
       .finally(() => {
       .finally(() => {
         if (
         if (

+ 1 - 0
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.",
   "chat_error": "Could not load chat messages, please try again.",
   "reconnect": "Try again",
   "reconnect": "Try again",
   "no_pdf_error_title": "No PDF",
   "no_pdf_error_title": "No PDF",