Bladeren bron

try catch in sending notification

sou 7 jaren geleden
bovenliggende
commit
ade2a28321
1 gewijzigde bestanden met toevoegingen van 13 en 8 verwijderingen
  1. 13 8
      lib/routes/comment.js

+ 13 - 8
lib/routes/comment.js

@@ -79,14 +79,19 @@ module.exports = function(crowi, app) {
 
 
     // slack notification
     // slack notification
     if (slackNotificationForm.isNotification) {
     if (slackNotificationForm.isNotification) {
-      const slackNotify = new slack(crowi);
-      const user = await User.findUserByUsername(req.user.username);
-      const path = page.path;
-      const channels = slackNotificationForm.notifSlackChannel;
-
-      channels.split(',').map(function(chan) {
-        slackNotify.postComment(createdComment, user, chan, path);
-      });
+      try {
+        const slackNotify = new slack(crowi);
+        const user = await User.findUserByUsername(req.user.username);
+        const path = page.path;
+        const channels = slackNotificationForm.notifSlackChannel;
+
+        channels.split(',').map(function(chan) {
+          slackNotify.postComment(createdComment, user, chan, path);
+        });
+      }
+      catch (err) {
+        console.log('error occured in sending slack notification: ', err);
+      }
     }
     }
 
 
     return res.json(ApiResponse.success({comment: createdComment}));
     return res.json(ApiResponse.success({comment: createdComment}));