aio-libs / aio-libs/aiohttp

Feature: make `HTTPException` non-abstract

オープン
#4,034 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Python
スター
16.5k
フォーク
2.4k
平均マージ
20時間 10分
マージ済み PR(30日)
221

説明

## 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 parameter `status_code`):
```
try:
...
except ClientResponseError as e:
status = e.status or 500
raise web.HTTPException(text=e.message, status_code=status)
```

Of course I can use `return web.Response(text=e.message, status=status)`, but `web.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)

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。