"""Global error handler: log exception and notify user.""" import logging from telegram import Update from telegram.ext import ContextTypes logger = logging.getLogger(__name__) async def error_handler(update: Update | None, context: ContextTypes.DEFAULT_TYPE) -> None: logger.exception("Exception while handling an update") if isinstance(update, Update) and update.effective_message: await update.effective_message.reply_text("Произошла ошибка. Попробуйте позже.")