L
L
Lynatik0012020-07-23 22:37:37
JavaScript
Lynatik001, 2020-07-23 22:37:37

Catching errors in JS node?

How can I catch the error in a practical, competent and readable way. - check bot token. In the telegram, (user enters a token, I check if it is a token) + attach further registration and actions (and this is not a couple of lines) - if this is still a token - i.e. tri-catch - worked without error

or can everything be implemented in another way much easier and shorter?

entryMenuScene.on('message', async (ctx) => {
      if (ctx.message.text.length <= 44) {
        await ctx.reply('Ошибка! Проверьте верность токена.');
      } else {
        try {
          const checkBot = new Telegraf(ctx.message.text);
          checkBot.launch();
        } catch (err) {
          console.log(err);
        }
      }
      return ctx.scene.reenter();
    });
    return entryMenuScene;
  }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question