Files
duty-teller/duty_teller/handlers/errors.py
Nikolay Tatarinov 86f6d66865
All checks were successful
CI / lint-and-test (push) Successful in 17s
chore: add changelog and documentation updates
- Created a new `CHANGELOG.md` file to document all notable changes to the project, adhering to the Keep a Changelog format.
- Updated `CONTRIBUTING.md` to include instructions for building and previewing documentation using MkDocs.
- Added `mkdocs.yml` configuration for documentation generation, including navigation structure and theme settings.
- Enhanced various documentation files, including API reference, architecture overview, configuration reference, and runbook, to provide comprehensive guidance for users and developers.
- Included new sections in the README for changelog and documentation links, improving accessibility to project information.
2026-02-20 15:32:10 +03:00

28 lines
881 B
Python

"""Global error handler: log exception and notify user."""
import logging
from telegram import Update
from telegram.ext import ContextTypes
import duty_teller.config as config
from duty_teller.i18n import get_lang, t
logger = logging.getLogger(__name__)
async def error_handler(
update: Update | None, context: ContextTypes.DEFAULT_TYPE
) -> None:
"""Global error handler: log exception and reply with generic message if possible.
Args:
update: Update that caused the error (may be None).
context: Callback context.
"""
logger.exception("Exception while handling an update")
if isinstance(update, Update) and update.effective_message:
user = getattr(update, "effective_user", None)
lang = get_lang(user) if user else config.DEFAULT_LANGUAGE
await update.effective_message.reply_text(t(lang, "errors.generic"))