Two errors specifically keep appearing in the console of my bot:
(node:4198) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: 403: Forbidden: bot was kicked from the group chat
(node:4198) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: 429: Too Many Requests: retry after 45
How do I handle these errors?
The docs and examples don't seem to mention this
Hey.
Seems like you just swallow Telegram errors.
bot.command('help', (ctx) => {
// Result of call just swallowed
ctx.reply('yo')
})
// You can just `pipe` call to upper level
// and hadle errors with telegraf: http://telegraf.js.org/introduction.html#error-handling
bot.command('help', (ctx) => {
return ctx.reply('yo')
})
// with `catch`
bot.command('help', (ctx) => {
ctx.reply('yo').catch((err) => console.log(err))
})
// with async/await style
bot.command('help', async (ctx) => {
try {
await ctx.reply('yo')
} catch (err) {
console.log(err)
}
})
Hrm, so I'd have to handle every single ctx.reply then..
Correct, you need to explicitly handle all Telegram errors.