Skip to content

Commit

Permalink
Fix xhr response behavior (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
lkemperman-cfa committed Aug 30, 2023
1 parent 8838b7c commit 3af922a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/main/resources/templates/fragments/fileUploader.html
Expand Up @@ -428,10 +428,24 @@
});
}
},

error: function (file, errorMessage, xhr) {
if (xhr && xhr.response) {
// redirect to client info page with intercepted param for error popup
location.href = "/flow/laDocUpload/clientInfo?intercepted=uploadDocuments"
const knownXhrErrors = [`[[${#messages.msg('upload-documents.error-mime-type')}]]`,
`[[${#messages.msg('upload-documents.this-file-is-too-large')}]]`,
`[[${#messages.msg('upload-documents.error-could-not-read-file')}]]`,
`[[${#messages.msg('upload-documents.error-password-protected')}]]`,
`[[${#messages.msg('upload-documents.error-maximum-number-of-files')}]]`
]

if (knownXhrErrors.includes(JSON.stringify(xhr.response))){
file.previewElement.getElementsByClassName("text--error")[0].innerText = xhr.response;

} else {
// redirect to client info page with intercepted param for error popup
location.href = "/flow/laDocUpload/clientInfo?intercepted=uploadDocuments"
}

} else {
var message = errorMessage.error ? errorMessage.error : errorMessage;
file.previewElement.getElementsByClassName("text--error")[0].innerText = message;
Expand Down

0 comments on commit 3af922a

Please sign in to comment.