Conversation
… display a error page if an error occur while loading a doucment
… triggle a error prompt and the step modal doesn't freeze the window
…ile corrputed in file system
|
@dennis-zyska I’ve addressed your requested changes and pushed an updated commit 5216562. Could you please take another look? @NilsDy FYI |
dennis-zyska
left a comment
There was a problem hiding this comment.
The solution with the text parsing with the error codes should be improved. We can change the function here: https://github.com/UKPLab/CARE/blob/main/backend/webserver/Socket.js#L86 and add a specific variables for the error code. It should be backward compatible. One possible solution would be to create an Error from the Error class and set the error code. If the error code is set, we send it back to the frontend, otherwise we use the previous solultion (in that way we don't need to adapt to much from the existing code). Here is a potential solution that could work: https://stackoverflow.com/a/69166148
| let filePath; | ||
| if (document.type === this.models['document'].docTypes.DOC_TYPE_HTML || | ||
| document.type === this.models['document'].docTypes.DOC_TYPE_MODAL) { | ||
| filePath = `${UPLOAD_PATH}/${document.hash}.delta`; |
There was a problem hiding this comment.
there is not always a delta file for HTML or MODAL documents and also no need, as every edit is still saved in the database. It is enough to only consider the PDF case.
frontend/src/components/Document.vue
Outdated
| /** | ||
| * Parse "ERROR_CODE|message" format from server error | ||
| */ | ||
| parseErrorMessage(raw) { |
There was a problem hiding this comment.
I'm not sure if it is a good idea to parse error codes like this, I can also find code in different components that is used the same time. Maybe we should integrate error codes properly.
…moved dead `documentError` socket listener
|
@dennis-zyska I’ve addressed your requested changes and pushed an updated commit. And also merged the latest dev into this bug fix branch. Could you please take another look? @NilsDy FYI |
backend/webserver/sockets/app.js
Outdated
|
|
||
| if (!record) { | ||
| // Record doesn't exist or was deleted | ||
| errorCode = "NOT_FOUND"; |
There was a problem hiding this comment.
Maybe we can create a new helper function in the utils/generic.js, such that we don't need 5 lines, to be able to reduce it, something like, as an example `throw new GenerateError("NOT_FOUND", "The request ..")
There was a problem hiding this comment.
I introduced a reusable generateError(code, message) helper in utils/generic.js and refactored this branch to use throw generateError(...) here (and in similar socket paths)
| this.close(); | ||
| }, | ||
|
|
||
| getErrorMessage(response) { |
There was a problem hiding this comment.
We define here the message and codes again, does this make sense? If we send all the data already from the backend to the frontend?
There was a problem hiding this comment.
I removed the duplicated local error-message map in LoadingModal and same function in other place such as Document.vue and now use backend-provided response.message directly, but I introduced a map titleMap between error code and title of the loading modal to provide more readable information in frontend.
…n in sockets and backend
…gic with `titleMap` so that front emits the same end error message and error cod as backend
|
@dennis-zyska I’ve addressed your requested changes and pushed an updated commit. And also merged the latest dev into this bug fix branch. Could you please take another look? @NilsDy FYI Also this PR could be reviewed within my team first, I'd assign it to one of team members for first review |
Goal: This patch aims to resolve the issue #10, addressing multiple bugs related to document validation. The main focus is on providing a better user experience when documents are missing, deleted, or inaccessible.
Key Changes:
Added a new
validateDocument()method inbackend/webserver/sockets/document.jsthat centralizes document validation logic:DOCUMENT_NOT_FOUND,ACCESS_DENIED,FILE_MISSING), details are in the comment [BUG] Error when document is not loaded #10 (comment), for consistent error handlingImproved UX - Error Pages Instead of Toasts. Replaced toast notifications with more informative error pages when documents are unavailable. Implemented in both
Document.vueandStudy.vuecomponents.Loading Modal Fixes. Fixed issue where the loading modal would freeze when encountering document errors. The result why
close()can not correctly terminate the loading modal seems to behide()deferred whenisShown=false, but component unmounts before deferred hide runs infrontend/src/basic/Modal.vue. Modal now properly closes and emits error events when a document cannot be loaded by replacinghide()withdispose()inbeforeunmount().Error messages are now consistent whether a file was deleted through the UI or is missing from the file system.
Demonstration:

Test accessing shared links to the document which has been deleted from the UI interface and from the filesystem accordingly.
Test accessing shared links to the study which uses a document which has been deleted from the UI interface and from the filesystem accordingly.
