Last active
January 11, 2022 07:32
-
-
Save yuvalherziger/612afa690ace7b12446625922677cad5 to your computer and use it in GitHub Desktop.
awaitables.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aiohttp.web import Request | |
from aiohttp_catcher import catch, Catcher | |
async def message(exc: MyException, request: Request): | |
return "This isn't allowed" | |
async def fields(exc: MyException, req: Request): | |
return { | |
"method": req.method, | |
"error_type": exc.some_error_class_attribute | |
} | |
async def main(): | |
# ... | |
catcher = Catcher() | |
await catcher.add_scenarios( | |
catch(MyException).with_status_code(401).and_call(message).with_additional_fields(fields), | |
) | |
#... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment