aio-libs / aio-libs/aiohttp

Feature: make `HTTPException` non-abstract

Đang mở
#4,034 5 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Python
Star
16.5k
Fork
2.4k
Merge trung bình
20 giờ 10 phút
Pull request đã merge (30 ngày)
221

Mô tả

## 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)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.