diff --git a/apps/bot/src/index.ts b/apps/bot/src/index.ts index 5e03ed6..94a5335 100644 --- a/apps/bot/src/index.ts +++ b/apps/bot/src/index.ts @@ -9,6 +9,12 @@ const bot = createBot({ token: environment.BOT_TOKEN, }); +bot.catch((error) => { + logger.error('Grammy bot error:'); + logger.error(`Message: ${error?.message}`); + logger.error(error.error); // собственно, ошибка +}); + const runner = run(bot); const redis = getRedisInstance(); @@ -36,4 +42,12 @@ async function gracefulShutdown(signal: string) { process.once('SIGINT', () => gracefulShutdown('SIGINT')); process.once('SIGTERM', () => gracefulShutdown('SIGTERM')); +process.on('unhandledRejection', (reason) => { + logger.error('Unhandled Rejection: ' + reason); +}); + +process.on('uncaughtException', (error) => { + logger.error('Uncaught Exception: ' + error); +}); + logger.info('Bot started');