소스 검색

add trycatch

Shun Miyazawa 4 년 전
부모
커밋
8777c8d286
1개의 변경된 파일11개의 추가작업 그리고 5개의 파일을 삭제
  1. 11 5
      packages/app/src/server/service/comment.ts

+ 11 - 5
packages/app/src/server/service/comment.ts

@@ -48,15 +48,21 @@ class CommentService {
 
     });
 
+    // update
     this.commentEvent.on('update', async(updatedComment) => {
-      this.commentEvent.onUpdate();
+      try {
+        this.commentEvent.onUpdate();
 
-      const savedActivity = await this.createCommentActivity(updatedComment, ActivityDefine.ACTION_COMMENT_UPDATE);
+        const savedActivity = await this.createCommentActivity(updatedComment, ActivityDefine.ACTION_COMMENT_UPDATE);
 
-      let targetUsers: Types.ObjectId[] = [];
-      targetUsers = await savedActivity.getNotificationTargetUsers();
+        let targetUsers: Types.ObjectId[] = [];
+        targetUsers = await savedActivity.getNotificationTargetUsers();
 
-      await this.inAppNotificationService.upsertByActivity(targetUsers, savedActivity);
+        await this.inAppNotificationService.upsertByActivity(targetUsers, savedActivity);
+      }
+      catch (err) {
+        logger.error('Error occurred while handling the comment update event:\n', err);
+      }
 
       // TODO: 79713
       // const { inAppNotificationService } = this.crowi;