Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handler wrong behaviour #898

Closed
Olegt0rr opened this issue Apr 26, 2022 · 0 comments
Closed

Error handler wrong behaviour #898

Olegt0rr opened this issue Apr 26, 2022 · 0 comments
Labels
3.x Issue or PR for stable 3.x version bug Something is wrong with the framework

Comments

@Olegt0rr
Copy link
Contributor

Context

Every handler type in aiogram receives own event type into first positional arguments:

  • message handler receives Message
  • callback_query handler receives CallbackQuery
  • poll handler receives Poll

Expected Behavior

  • error handler receives Exception

This behaviour also described in the docs:
https://docs.aiogram.dev/en/dev-3.x/dispatcher/router.html#errors

Current Behavior

  • error handler receives Update

Steps to Reproduce

import logging

from aiogram import Bot, Dispatcher, types

TOKEN = "42:token"

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

dp = Dispatcher()


@dp.message()
async def echo_handler(message: types.Message) -> None:
    raise Exception("Test exception")


@dp.errors()
async def error_handler(first) -> None:
    logger.warning("First argument type: %s", type(first).__name__)


if __name__ == "__main__":
    bot = Bot(TOKEN, parse_mode="HTML")
    dp.run_polling(bot)
@Olegt0rr Olegt0rr added bug Something is wrong with the framework breaking This breaks backwards-compatibility 3.x Issue or PR for stable 3.x version labels Apr 26, 2022
@evgfilim1 evgfilim1 removed the breaking This breaks backwards-compatibility label Jun 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issue or PR for stable 3.x version bug Something is wrong with the framework
Projects
None yet
Development

No branches or pull requests

3 participants