Skip to content

Sentry doesn't capture aiohttp exception? #642

@lopatinay

Description

@lopatinay

I followed an example https://docs.sentry.io/platforms/python/aiohttp/ and first thing I did

async def hello(request):
    print(1/0)

It's work fine and I got this Sentry Issue. But, when you try

async def hello(request):
    raise web_exceptions.HTTPInternalServerError  # any aiohttp exception

you won't get any Sentry Issue.
Is the only way to catch errors to use middleware?

async def errors_handler(request, handler):
    try:
        response = await handler(request)
    except web.HTTPException as e:
        capture_exception(e)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions