add error message for unsupported file
This commit is contained in:
@@ -17,14 +17,23 @@ export async function searchUserFiles(fileId: string) {
|
||||
if (parsed.message_code === 0) {
|
||||
return parsed.message_body;
|
||||
} else {
|
||||
throw parsed;
|
||||
throw parsed.message_desc;
|
||||
}
|
||||
} else {
|
||||
throw (`${response.status}`);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
return error
|
||||
|
||||
if (error === 'File for search unsupported') {
|
||||
return {
|
||||
errorMessage: 'file-for-search-unsupported'
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
errorMessage: 'error'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,11 @@ export function FileSearchPanel(
|
||||
try {
|
||||
let result = await searchUserFiles(fileId);
|
||||
|
||||
if (result.content.length) {
|
||||
if (result.errorMessage) {
|
||||
throw result.errorMessage
|
||||
}
|
||||
|
||||
if (result?.content?.length) {
|
||||
setSearchedUserFiles(result.content);
|
||||
if (fileType === 'image') {
|
||||
setShowGlobalSearch(true);
|
||||
@@ -80,7 +84,12 @@ export function FileSearchPanel(
|
||||
setSearchedUserFilesShowNull(true);
|
||||
}
|
||||
} catch (error) {
|
||||
setErrorMessage('error');
|
||||
|
||||
if (error === 'file-for-search-unsupported') {
|
||||
setErrorMessage(error);
|
||||
} else {
|
||||
setErrorMessage('search-error');
|
||||
}
|
||||
}
|
||||
|
||||
}, [fileId])
|
||||
@@ -138,7 +147,7 @@ export function FileSearchPanel(
|
||||
|
||||
{errorMessage && (
|
||||
<div className='mt-2 text-red-600 text-sm'>
|
||||
{t('search-error')}
|
||||
{t(errorMessage)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -286,7 +286,8 @@
|
||||
"DIFFERENT": "DIFFERENT",
|
||||
"file-information": "File information",
|
||||
"id-in-the-system": "ID in the system",
|
||||
"protection-status": "Protection status"
|
||||
"protection-status": "Protection status",
|
||||
"file-for-search-unsupported": "File for search unsupported"
|
||||
},
|
||||
"Login-register-form": {
|
||||
"and": "and",
|
||||
|
||||
@@ -286,7 +286,8 @@
|
||||
"DIFFERENT": "ДРУГОЙ",
|
||||
"file-information": "Информация о файле",
|
||||
"id-in-the-system": "ID в системе",
|
||||
"protection-status": "Статус защиты"
|
||||
"protection-status": "Статус защиты",
|
||||
"file-for-search-unsupported": "Файл для поиска не поддерживается"
|
||||
},
|
||||
"Login-register-form": {
|
||||
"and": "и",
|
||||
|
||||
Reference in New Issue
Block a user