UNPKG

@wasserstoff/mangi-tg-bot

Version:

A powerful Telegram Bot SDK with built-in authentication, session management, and database integration

37 lines 1.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.errorHandler = void 0; const logger_1 = require("./logger"); const errorHandler = async (error) => { const { ctx } = error; // Log the error ctx.logger.error({ err: error.error, update: (0, logger_1.getUpdateInfo)(ctx), }); // Handle callback query errors specifically if (ctx.callbackQuery) { try { // Try to answer the callback query with an error message await ctx.answerCallbackQuery({ text: "An error occurred while processing your request", show_alert: false }); } catch (callbackError) { // If we can't answer the callback query (e.g., it's already timed out), just log it ctx.logger.error("Failed to answer callback query after error:", callbackError); } } // For other types of errors, try to send a message to the user if (ctx.chat && ctx.message && !ctx.callbackQuery) { try { await ctx.reply("Sorry, an error occurred while processing your request. Please try again."); } catch (replyError) { ctx.logger.error("Failed to send error message to user:", replyError); } } }; exports.errorHandler = errorHandler; //# sourceMappingURL=errorHandler.js.map