Skip to content

Commit 7c236f6

Browse files
committed
Added try-catch block to announcement service to log errors when sending messages
1 parent 526f134 commit 7c236f6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/bot/services/handling/announcement/announcement.service.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ export class GlobalAnnouncementService {
4040
}
4141
users.forEach(async (user) => {
4242
if (user.tgId !== msg.chat.id) {
43-
await bot.sendMessage(user.tgId, msg.text, {
44-
parse_mode: 'HTML',
45-
})
43+
try {
44+
await bot.sendMessage(user.tgId, msg.text, {
45+
parse_mode: 'HTML',
46+
})
47+
} catch (error) {
48+
console.error(error)
49+
}
4650
}
4751
})
4852
await this.userService.update(msg.chat.id, {

0 commit comments

Comments
 (0)