Add error handling to group parsing in chat search

This commit is contained in:
Cohee 2024-12-04 01:05:14 +02:00
parent 36051fa5db
commit 8ef49b40b2

View File

@ -561,10 +561,14 @@ router.post('/search', jsonParser, function (request, response) {
let targetGroup; let targetGroup;
for (const groupFile of groupFiles) { for (const groupFile of groupFiles) {
const groupData = JSON.parse(fs.readFileSync(path.join(groupDir, groupFile), 'utf8')); try {
if (groupData.id === group_id) { const groupData = JSON.parse(fs.readFileSync(path.join(groupDir, groupFile), 'utf8'));
targetGroup = groupData; if (groupData.id === group_id) {
break; targetGroup = groupData;
break;
}
} catch (error) {
console.error(groupFile, 'group file is corrupted:', error);
} }
} }