-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Feature: make HTTPException
non-abstract
#4034
Comments
Thanks for the interesting question. Python's I prefer a factory function, e.g. Feel free to make a pull request. I have a feeling that the feature priority is low; don't want to work on it personally but happy to help with the review. |
I'd even say a |
Earlier I used to apply class methods often enough but now I prefer just a function usually. It gives better decomposability but provides the same functionality. The taste question though. |
Some HTTPException subclasses require additional arguments. For example |
I thought that the factory accepts As an alternative, we can do nothing. The issue is useful only for writing some kind of proxy that passes HTTP codes from internal HTTP calls to its own caller as is. aiohttp is used for building microservices/proxies/aggregators often enough, maybe the idea has own fellows. I have no strong preference here (and don't want to invest my own time in the implementation but open for review). |
Long story short
Use-case: a server's handler uses a client to make a request to another server. I would like to re-use the response status code in the first server's response (the code below does not work as
HTTPException
's constructor does not accept parameterstatus_code
):Of course I can use
return web.Response(text=e.message, status=status)
, butweb.Response
cannot be throwed, however I need it in my applicatoin.Expected behaviour
I would expect
web.HTTPException
not to be abstract so that one can construct and raise it with a dynamic status code.Actual behaviour
one cannot create an instance of
web.HTTPException
Steps to reproduce
(not a bug so no steps to reproduce)
Your environment
(not a bug so no environment description)
The text was updated successfully, but these errors were encountered: