Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error is not processed by nest logger when wrong token is passed #1260

Open
Mittcio opened this issue Dec 8, 2024 · 1 comment
Open

Error is not processed by nest logger when wrong token is passed #1260

Mittcio opened this issue Dec 8, 2024 · 1 comment

Comments

@Mittcio
Copy link

Mittcio commented Dec 8, 2024

Generate error what is not handled by nest logger if wrong token is passed for example https://github.com/robot-mafia/nestjs-telegraf/blob/194419dc799f0872fcf4000a5e1266c462dac8c7/lib/utils/create-bot-factory.util.ts#L16

const bot = new Telegraf<any>(options.token, options.options);

  bot.use(...(options.middlewares ?? []));
  bot.catch((err, ctx) =>
    Logger.error(err, `Telegraf: ${ctx.botInfo.username}`), // that not help
  );

  if (options.launchOptions !== false) {
    bot.launch(options.launchOptions);  // here thrown error
  }

Can catch it with

if (options.launchOptions !== false) {
    bot
      .launch(options.launchOptions)
      .catch((err) => Logger.error(err.stack, 'Telegraf')); // that
  }
@Mittcio
Copy link
Author

Mittcio commented Dec 8, 2024

With that change will be

[NestApp] 10000  - 12/08/2024, 1:00:00 PM   ERROR [Telegraf] Error: 404: Not Found
    at new TelegramError (/home/projects/app/node_modules/telegraf/lib/core/network/error.js:6:9)
    at <anonymous> (/home/projects/app/node_modules/telegraf/lib/core/network/client.js:315:31)
    at processTicksAndRejections (native:7:39)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant