Skip to content

Commit 9bc0cff

Browse files
committed
Add try/catch
1 parent 174c628 commit 9bc0cff

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

src/resolvers/project.js

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -59,33 +59,37 @@ module.exports = {
5959
let project = await factories.projectsFactory.create(options);
6060
const userData = await factories.usersFactory.findById(user.id);
6161

62-
await project.createNotificationsRule({
63-
isEnabled: true,
64-
whatToReceive: ReceiveTypes.SEEN_MORE,
65-
including: [],
66-
excluding: [],
67-
threshold: 20,
68-
thresholdPeriod: 3600000,
69-
channels: {
70-
email: {
71-
isEnabled: true,
72-
endpoint: userData.email,
73-
minPeriod: 60,
74-
},
75-
telegram: {
76-
isEnabled: false,
77-
endpoint: '',
78-
minPeriod: 60,
79-
},
80-
slack: {
81-
isEnabled: false,
82-
endpoint: '',
83-
minPeriod: 60,
62+
try {
63+
await project.createNotificationsRule({
64+
isEnabled: true,
65+
whatToReceive: ReceiveTypes.SEEN_MORE,
66+
including: [],
67+
excluding: [],
68+
threshold: 20,
69+
thresholdPeriod: 3600000,
70+
channels: {
71+
email: {
72+
isEnabled: true,
73+
endpoint: userData.email,
74+
minPeriod: 60,
75+
},
76+
telegram: {
77+
isEnabled: false,
78+
endpoint: '',
79+
minPeriod: 60,
80+
},
81+
slack: {
82+
isEnabled: false,
83+
endpoint: '',
84+
minPeriod: 60,
85+
},
8486
},
85-
},
86-
});
87+
});
8788

88-
project = await factories.projectsFactory.findById(project._id);
89+
project = await factories.projectsFactory.findById(project._id);
90+
} catch (err) {
91+
telegram.sendMessage(`❌ Failed to enable default notifications for project ${name}`);
92+
}
8993

9094
/**
9195
* Create collections for storing events and setup indexes

0 commit comments

Comments
 (0)