{"id":17543135,"url":"https://github.com/zzzsochi/aiohttp_exc_handlers","last_synced_at":"2025-03-29T05:16:21.026Z","repository":{"id":41073712,"uuid":"45758824","full_name":"zzzsochi/aiohttp_exc_handlers","owner":"zzzsochi","description":"Bind views to exceptions for aiohttp","archived":false,"fork":false,"pushed_at":"2016-01-19T17:53:12.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-03T14:51:53.489Z","etag":null,"topics":["aiohttp","aiohttp-server","asyncio","exception-handler","exception-handling"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zzzsochi.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-07T23:17:42.000Z","updated_at":"2017-10-31T21:01:58.000Z","dependencies_parsed_at":"2022-09-26T17:11:07.055Z","dependency_job_id":null,"html_url":"https://github.com/zzzsochi/aiohttp_exc_handlers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzzsochi%2Faiohttp_exc_handlers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzzsochi%2Faiohttp_exc_handlers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzzsochi%2Faiohttp_exc_handlers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzzsochi%2Faiohttp_exc_handlers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zzzsochi","download_url":"https://codeload.github.com/zzzsochi/aiohttp_exc_handlers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246140591,"owners_count":20729802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aiohttp","aiohttp-server","asyncio","exception-handler","exception-handling"],"created_at":"2024-10-21T00:22:59.502Z","updated_at":"2025-03-29T05:16:20.996Z","avatar_url":"https://github.com/zzzsochi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"====================================\nBind views to exceptions for aiohttp\n====================================\n\n.. image:: https://travis-ci.org/zzzsochi/aiohttp_exc_handlers.svg?branch=master\n  :target:  https://travis-ci.org/zzzsochi/aiohttp_exc_handlers\n  :align: right\n\n.. image:: https://coveralls.io/repos/zzzsochi/aiohttp_exc_handlers/badge.svg\n  :target:  https://coveralls.io/github/zzzsochi/aiohttp_exc_handlers\n  :align: right\n\n-----\nUsage\n-----\n\n.. code:: python\n\n    import asyncio\n\n    from aiohttp import web\n    from aiohttp_exc_handlers import (\n        exc_handlers_middleware,\n        bind_exc_handler,\n    )\n\n\n    class CustomException(Exception):\n        pass\n\n\n    async def custom_exception_handler(request, exc):\n        return web.Response(text=\"Hello, {!s}!\".format(exc))\n\n\n    async def hello(request):\n        raise CustomException('world')\n\n\n    # add middleware\n    app = web.Application(middlewares=[exc_handlers_middleware])\n\n    # bind handler to exception\n    bind_exc_handler(app, CustomException, custom_exception_handler)\n\n    app.router.add_route('GET', '/', hello)\n\n    loop = asyncio.get_event_loop()\n    handler = app.make_handler()\n    f = loop.create_server(handler, '0.0.0.0', 8080)\n    srv = loop.run_until_complete(f)\n\n    try:\n        loop.run_forever()\n    except KeyboardInterrupt:\n        pass\n    finally:\n        loop.run_until_complete(handler.finish_connections(1.0))\n        srv.close()\n        loop.run_until_complete(srv.wait_closed())\n        loop.run_until_complete(app.finish())\n\n    loop.close()\n\n\n-----\nTests\n-----\n\n.. code:: shell\n\n    $ pip install pytest\n    $ py.test tests.py\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzzzsochi%2Faiohttp_exc_handlers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzzzsochi%2Faiohttp_exc_handlers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzzzsochi%2Faiohttp_exc_handlers/lists"}