feat: add error handler to bot for better error logging

This will help catch and log errors that were previously
showing as "No error handlers are registered"
This commit is contained in:
shokollm
2026-04-04 23:59:07 +00:00
parent 858305ebac
commit ec29e4f15f

View File

@@ -43,6 +43,10 @@ from config import config
BOT_TOKEN = config.bot_token or "" BOT_TOKEN = config.bot_token or ""
async def error_handler(update, context):
log.error(f"Error: {context.error}")
def build_app() -> Application: def build_app() -> Application:
app = Application.builder().token(BOT_TOKEN).build() app = Application.builder().token(BOT_TOKEN).build()
@@ -65,6 +69,8 @@ def build_app() -> Application:
app.add_handler(MessageHandler(filters.COMMAND, cmd_help)) app.add_handler(MessageHandler(filters.COMMAND, cmd_help))
app.add_error_handler(error_handler)
return app return app