Add error handling to group parsing in chat search

8ef49b40b230a50b70a92d1eee245f76978efbb9

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +4 -0Showing whitespace changes
src/endpoints/chats.js+4 -0
@@ -561,11 +561,15 @@ router.post('/search', jsonParser, function (request, response) {
561561
562562 let targetGroup;
563563 for (const groupFile of groupFiles) {
564+ try {
564565 const groupData = JSON.parse(fs.readFileSync(path.join(groupDir, groupFile), 'utf8'));
565566 if (groupData.id === group_id) {
566567 targetGroup = groupData;
567568 break;
568569 }
570+ } catch (error) {
571+ console.error(groupFile, 'group file is corrupted:', error);
572+ }
569573 }
570574
571575 if (!targetGroup?.chats) {