Skip to content

Commit

Permalink
chore: Update error handling and launch method in index.js
Browse files Browse the repository at this point in the history
chore: Refactor error handling and launch method in index.js

chore: Refactor error handling and launch method in index.js
  • Loading branch information
gnehs committed Jul 19, 2024
1 parent 0ccdc79 commit fc9c655
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
const { Telegraf } = require("telegraf");
const bot = new Telegraf(process.env.BOT_TOKEN);
bot.catch((err, ctx) => {
console.log(`Ooops, encountered an error for ${ctx.updateType}`);
console.log(err);
});

// components
bot.use(
Expand All @@ -17,8 +13,9 @@ bot.use(
require("./components/subscribe/index")
);

bot.catch((err) => {
console.log("[error]", err);
});

bot.launch();

// catch error
process.on("unhandledRejection", (error) => {
console.error(error);
});

0 comments on commit fc9c655

Please sign in to comment.