Skip to content

Some option to call raise_for_status() automatically on any request. #1724

Closed
@socketpair

Description

I have many places where my application issues HTTP-request, for example:

async def get_network_interfaces():
    async with ClientSession() as session:
        async with session.get('http://localhost/network/interfaces') as response:
            response.raise_for_status()  # <- THIS LINE
            return await response.json()

The marked line annoys me, since our programmes forgot to add it too frequently. Unforunatelly, our web services report error with HTTP code 542 and JSON-response of error, so returning from such functions without exception is a bug.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions