sanic-org/sanic

ASGI exceptions outside handlers should be able to pass status

开放

#2,718 创建于 2023年3月19日

 (0 条评论) (0 个反应) (0 位负责人)Python (1,515 个派生)batch import
beginnerhelp wanted

仓库指标

星标
 (17,623 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

An exception raised in the lifecycle (but not handler) of a request on an ASGI-served application should be able to pass a status code.


In my experiment, raising a BadRequest in asgi.py will cause the ASGI server return 500 error, instead of 400. This seems out of the scope of this PR, but I am wondering whether we should change the raised error to ServerError or others before we figure out how to let ASGI server return a 400 error.

Originally posted by @ChihweiLHBird in https://github.com/sanic-org/sanic/pull/2606#discussion_r1133448078

贡献者指南