add error message for unsupported file

This commit is contained in:
smanylov
2026-03-03 13:25:26 +07:00
parent 2227a842ae
commit 3e3a5df34d
4 changed files with 27 additions and 7 deletions
+11 -2
View File
@@ -17,14 +17,23 @@ export async function searchUserFiles(fileId: string) {
if (parsed.message_code === 0) { if (parsed.message_code === 0) {
return parsed.message_body; return parsed.message_body;
} else { } else {
throw parsed; throw parsed.message_desc;
} }
} else { } else {
throw (`${response.status}`); throw (`${response.status}`);
} }
} catch (error) { } catch (error) {
return error
if (error === 'File for search unsupported') {
return {
errorMessage: 'file-for-search-unsupported'
}
} else {
return {
errorMessage: 'error'
}
}
} }
} }
+12 -3
View File
@@ -70,7 +70,11 @@ export function FileSearchPanel(
try { try {
let result = await searchUserFiles(fileId); let result = await searchUserFiles(fileId);
if (result.content.length) { if (result.errorMessage) {
throw result.errorMessage
}
if (result?.content?.length) {
setSearchedUserFiles(result.content); setSearchedUserFiles(result.content);
if (fileType === 'image') { if (fileType === 'image') {
setShowGlobalSearch(true); setShowGlobalSearch(true);
@@ -80,7 +84,12 @@ export function FileSearchPanel(
setSearchedUserFilesShowNull(true); setSearchedUserFilesShowNull(true);
} }
} catch (error) { } catch (error) {
setErrorMessage('error');
if (error === 'file-for-search-unsupported') {
setErrorMessage(error);
} else {
setErrorMessage('search-error');
}
} }
}, [fileId]) }, [fileId])
@@ -138,7 +147,7 @@ export function FileSearchPanel(
{errorMessage && ( {errorMessage && (
<div className='mt-2 text-red-600 text-sm'> <div className='mt-2 text-red-600 text-sm'>
{t('search-error')} {t(errorMessage)}
</div> </div>
)} )}
</div> </div>
+2 -1
View File
@@ -286,7 +286,8 @@
"DIFFERENT": "DIFFERENT", "DIFFERENT": "DIFFERENT",
"file-information": "File information", "file-information": "File information",
"id-in-the-system": "ID in the system", "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": { "Login-register-form": {
"and": "and", "and": "and",
+2 -1
View File
@@ -286,7 +286,8 @@
"DIFFERENT": "ДРУГОЙ", "DIFFERENT": "ДРУГОЙ",
"file-information": "Информация о файле", "file-information": "Информация о файле",
"id-in-the-system": "ID в системе", "id-in-the-system": "ID в системе",
"protection-status": "Статус защиты" "protection-status": "Статус защиты",
"file-for-search-unsupported": "Файл для поиска не поддерживается"
}, },
"Login-register-form": { "Login-register-form": {
"and": "и", "and": "и",