update error handler
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user