update error handler

This commit is contained in:
smanylov
2026-02-04 16:10:16 +07:00
parent 40fa737208
commit e778cf7e33
6 changed files with 53 additions and 24 deletions
+12 -10
View File
@@ -234,15 +234,11 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
formData.append('upload_id', response.upload_id);
formData.append('chunk_number', chunkIndex.toString());
formData.append('chunk', chunk);
/* formData.append('findSimilar', '0'); */
const chunkResponse = await chunkUpload(formData);
if (chunkResponse.message_desc !== 'Chunk uploaded successfully') {
if (chunkResponse.message_desc === 'Duplicate file upload') {
throw (`duplicate-file`);
}
throw new Error(`Chunk ${chunkIndex} upload failed`);
if (chunkResponse.errorMesage !== null) {
throw chunkResponse.errorMesage;
}
setUploadProgress(Math.floor((chunkIndex + 1) / totalChunks * 100));
@@ -260,10 +256,16 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
} catch (error) {
if (!isCancelledRef.current) {
if (error === 'duplicate-file') {
setErrorHandler(t('error-duplicate-file'));
} else {
setErrorHandler(t('error-uploading-file'));
switch (error) {
case 'duplicate-file':
setErrorHandler(t('error-duplicate-file'));
break;
case 'user-not-have-tokens-for-protect':
setErrorHandler(t('error-user-not-have-tokens-for-protect'));
break;
default:
setErrorHandler(t('error-uploading-file'));
break;
}
}
} finally {